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

Function processUpdateQueue

code/controlled-uncontrolled/public/app.js:7318–7452  ·  view source on GitHub ↗
(current, workInProgress, queue, instance, props, renderExpirationTime)

Source from the content-addressed store, hash-verified

7316}
7317
7318function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) {
7319 if (current !== null && current.updateQueue === queue) {
7320 // We need to create a work-in-progress queue, by cloning the current queue.
7321 var currentQueue = queue;
7322 queue = workInProgress.updateQueue = {
7323 baseState: currentQueue.baseState,
7324 expirationTime: currentQueue.expirationTime,
7325 first: currentQueue.first,
7326 last: currentQueue.last,
7327 isInitialized: currentQueue.isInitialized,
7328 capturedValues: currentQueue.capturedValues,
7329 // These fields are no longer valid because they were already committed.
7330 // Reset them.
7331 callbackList: null,
7332 hasForceUpdate: false
7333 };
7334 }
7335
7336 {
7337 // Set this flag so we can warn if setState is called inside the update
7338 // function of another setState.
7339 queue.isProcessing = true;
7340 }
7341
7342 // Reset the remaining expiration time. If we skip over any updates, we'll
7343 // increase this accordingly.
7344 queue.expirationTime = NoWork;
7345
7346 // TODO: We don't know what the base state will be until we begin work.
7347 // It depends on which fiber is the next current. Initialize with an empty
7348 // base state, then set to the memoizedState when rendering. Not super
7349 // happy with this approach.
7350 var state = void 0;
7351 if (queue.isInitialized) {
7352 state = queue.baseState;
7353 } else {
7354 state = queue.baseState = workInProgress.memoizedState;
7355 queue.isInitialized = true;
7356 }
7357 var dontMutatePrevState = true;
7358 var update = queue.first;
7359 var didSkip = false;
7360 while (update !== null) {
7361 var updateExpirationTime = update.expirationTime;
7362 if (updateExpirationTime > renderExpirationTime) {
7363 // This update does not have sufficient priority. Skip it.
7364 var remainingExpirationTime = queue.expirationTime;
7365 if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) {
7366 // Update the remaining expiration time.
7367 queue.expirationTime = updateExpirationTime;
7368 }
7369 if (!didSkip) {
7370 didSkip = true;
7371 queue.baseState = state;
7372 }
7373 // Continue to the next update.
7374 update = update.next;
7375 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