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

Function insertUpdateIntoFiber

code/communication/public/app.js:7972–8004  ·  view source on GitHub ↗
(fiber, update)

Source from the content-addressed store, hash-verified

7970}
7971
7972function insertUpdateIntoFiber(fiber, update) {
7973 ensureUpdateQueues(fiber);
7974 var queue1 = q1;
7975 var queue2 = q2;
7976
7977 // Warn if an update is scheduled from inside an updater function.
7978 {
7979 if ((queue1.isProcessing || queue2 !== null && queue2.isProcessing) && !didWarnUpdateInsideUpdate) {
7980 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.');
7981 didWarnUpdateInsideUpdate = true;
7982 }
7983 }
7984
7985 // If there's only one queue, add the update to that queue and exit.
7986 if (queue2 === null) {
7987 insertUpdateIntoQueue(queue1, update);
7988 return;
7989 }
7990
7991 // If either queue is empty, we need to add to both queues.
7992 if (queue1.last === null || queue2.last === null) {
7993 insertUpdateIntoQueue(queue1, update);
7994 insertUpdateIntoQueue(queue2, update);
7995 return;
7996 }
7997
7998 // If both lists are not empty, the last update is the same for both lists
7999 // because of structural sharing. So, we should only append to one of
8000 // the lists.
8001 insertUpdateIntoQueue(queue1, update);
8002 // But we still need to update the `last` pointer of queue2.
8003 queue2.last = update;
8004}
8005
8006function getUpdateExpirationTime(fiber) {
8007 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