MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / processUpdateQueue

Function processUpdateQueue

code/new-context-api/public/app.js:7355–7489  ·  view source on GitHub ↗
(current, workInProgress, queue, instance, props, renderExpirationTime)

Source from the content-addressed store, hash-verified

7353}
7354
7355function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) {
7356 if (current !== null && current.updateQueue === queue) {
7357 // We need to create a work-in-progress queue, by cloning the current queue.
7358 var currentQueue = queue;
7359 queue = workInProgress.updateQueue = {
7360 baseState: currentQueue.baseState,
7361 expirationTime: currentQueue.expirationTime,
7362 first: currentQueue.first,
7363 last: currentQueue.last,
7364 isInitialized: currentQueue.isInitialized,
7365 capturedValues: currentQueue.capturedValues,
7366 // These fields are no longer valid because they were already committed.
7367 // Reset them.
7368 callbackList: null,
7369 hasForceUpdate: false
7370 };
7371 }
7372
7373 {
7374 // Set this flag so we can warn if setState is called inside the update
7375 // function of another setState.
7376 queue.isProcessing = true;
7377 }
7378
7379 // Reset the remaining expiration time. If we skip over any updates, we'll
7380 // increase this accordingly.
7381 queue.expirationTime = NoWork;
7382
7383 // TODO: We don't know what the base state will be until we begin work.
7384 // It depends on which fiber is the next current. Initialize with an empty
7385 // base state, then set to the memoizedState when rendering. Not super
7386 // happy with this approach.
7387 var state = void 0;
7388 if (queue.isInitialized) {
7389 state = queue.baseState;
7390 } else {
7391 state = queue.baseState = workInProgress.memoizedState;
7392 queue.isInitialized = true;
7393 }
7394 var dontMutatePrevState = true;
7395 var update = queue.first;
7396 var didSkip = false;
7397 while (update !== null) {
7398 var updateExpirationTime = update.expirationTime;
7399 if (updateExpirationTime > renderExpirationTime) {
7400 // This update does not have sufficient priority. Skip it.
7401 var remainingExpirationTime = queue.expirationTime;
7402 if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) {
7403 // Update the remaining expiration time.
7404 queue.expirationTime = updateExpirationTime;
7405 }
7406 if (!didSkip) {
7407 didSkip = true;
7408 queue.baseState = state;
7409 }
7410 // Continue to the next update.
7411 update = update.next;
7412 continue;

Callers 4

mountClassInstanceFunction · 0.70
resumeMountClassInstanceFunction · 0.70
updateClassInstanceFunction · 0.70
updateHostRootFunction · 0.70

Calls 1

getStateFromUpdateFunction · 0.70

Tested by

no test coverage detected