MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / processUpdateQueue

Function processUpdateQueue

code/higher-order-components/public/app.js:7988–8122  ·  view source on GitHub ↗
(current, workInProgress, queue, instance, props, renderExpirationTime)

Source from the content-addressed store, hash-verified

7986}
7987
7988function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) {
7989 if (current !== null && current.updateQueue === queue) {
7990 // We need to create a work-in-progress queue, by cloning the current queue.
7991 var currentQueue = queue;
7992 queue = workInProgress.updateQueue = {
7993 baseState: currentQueue.baseState,
7994 expirationTime: currentQueue.expirationTime,
7995 first: currentQueue.first,
7996 last: currentQueue.last,
7997 isInitialized: currentQueue.isInitialized,
7998 capturedValues: currentQueue.capturedValues,
7999 // These fields are no longer valid because they were already committed.
8000 // Reset them.
8001 callbackList: null,
8002 hasForceUpdate: false
8003 };
8004 }
8005
8006 {
8007 // Set this flag so we can warn if setState is called inside the update
8008 // function of another setState.
8009 queue.isProcessing = true;
8010 }
8011
8012 // Reset the remaining expiration time. If we skip over any updates, we'll
8013 // increase this accordingly.
8014 queue.expirationTime = NoWork;
8015
8016 // TODO: We don't know what the base state will be until we begin work.
8017 // It depends on which fiber is the next current. Initialize with an empty
8018 // base state, then set to the memoizedState when rendering. Not super
8019 // happy with this approach.
8020 var state = void 0;
8021 if (queue.isInitialized) {
8022 state = queue.baseState;
8023 } else {
8024 state = queue.baseState = workInProgress.memoizedState;
8025 queue.isInitialized = true;
8026 }
8027 var dontMutatePrevState = true;
8028 var update = queue.first;
8029 var didSkip = false;
8030 while (update !== null) {
8031 var updateExpirationTime = update.expirationTime;
8032 if (updateExpirationTime > renderExpirationTime) {
8033 // This update does not have sufficient priority. Skip it.
8034 var remainingExpirationTime = queue.expirationTime;
8035 if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) {
8036 // Update the remaining expiration time.
8037 queue.expirationTime = updateExpirationTime;
8038 }
8039 if (!didSkip) {
8040 didSkip = true;
8041 queue.baseState = state;
8042 }
8043 // Continue to the next update.
8044 update = update.next;
8045 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