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

Function insertUpdateIntoFiber

code/new-context-api/public/app.js:7298–7330  ·  view source on GitHub ↗
(fiber, update)

Source from the content-addressed store, hash-verified

7296}
7297
7298function insertUpdateIntoFiber(fiber, update) {
7299 ensureUpdateQueues(fiber);
7300 var queue1 = q1;
7301 var queue2 = q2;
7302
7303 // Warn if an update is scheduled from inside an updater function.
7304 {
7305 if ((queue1.isProcessing || queue2 !== null && queue2.isProcessing) && !didWarnUpdateInsideUpdate) {
7306 warning(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
7307 didWarnUpdateInsideUpdate = true;
7308 }
7309 }
7310
7311 // If there's only one queue, add the update to that queue and exit.
7312 if (queue2 === null) {
7313 insertUpdateIntoQueue(queue1, update);
7314 return;
7315 }
7316
7317 // If either queue is empty, we need to add to both queues.
7318 if (queue1.last === null || queue2.last === null) {
7319 insertUpdateIntoQueue(queue1, update);
7320 insertUpdateIntoQueue(queue2, update);
7321 return;
7322 }
7323
7324 // If both lists are not empty, the last update is the same for both lists
7325 // because of structural sharing. So, we should only append to one of
7326 // the lists.
7327 insertUpdateIntoQueue(queue1, update);
7328 // But we still need to update the `last` pointer of queue2.
7329 queue2.last = update;
7330}
7331
7332function getUpdateExpirationTime(fiber) {
7333 switch (fiber.tag) {

Callers 3

ReactFiberClassComponentFunction · 0.70
scheduleCaptureFunction · 0.70
scheduleRootUpdateFunction · 0.70

Calls 3

warningFunction · 0.85
ensureUpdateQueuesFunction · 0.70
insertUpdateIntoQueueFunction · 0.70

Tested by

no test coverage detected