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

Function insertUpdateIntoFiber

code/third-party/public/app.js:7170–7202  ·  view source on GitHub ↗
(fiber, update)

Source from the content-addressed store, hash-verified

7168}
7169
7170function insertUpdateIntoFiber(fiber, update) {
7171 ensureUpdateQueues(fiber);
7172 var queue1 = q1;
7173 var queue2 = q2;
7174
7175 // Warn if an update is scheduled from inside an updater function.
7176 {
7177 if ((queue1.isProcessing || queue2 !== null && queue2.isProcessing) && !didWarnUpdateInsideUpdate) {
7178 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.');
7179 didWarnUpdateInsideUpdate = true;
7180 }
7181 }
7182
7183 // If there's only one queue, add the update to that queue and exit.
7184 if (queue2 === null) {
7185 insertUpdateIntoQueue(queue1, update);
7186 return;
7187 }
7188
7189 // If either queue is empty, we need to add to both queues.
7190 if (queue1.last === null || queue2.last === null) {
7191 insertUpdateIntoQueue(queue1, update);
7192 insertUpdateIntoQueue(queue2, update);
7193 return;
7194 }
7195
7196 // If both lists are not empty, the last update is the same for both lists
7197 // because of structural sharing. So, we should only append to one of
7198 // the lists.
7199 insertUpdateIntoQueue(queue1, update);
7200 // But we still need to update the `last` pointer of queue2.
7201 queue2.last = update;
7202}
7203
7204function getUpdateExpirationTime(fiber) {
7205 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