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

Function propagateContextChange

code/third-party/public/app.js:9461–9535  ·  view source on GitHub ↗
(workInProgress, context, changedBits, renderExpirationTime)

Source from the content-addressed store, hash-verified

9459 }
9460
9461 function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
9462 var fiber = workInProgress.child;
9463 if (fiber !== null) {
9464 // Set the return pointer of the child to the work-in-progress fiber.
9465 fiber['return'] = workInProgress;
9466 }
9467 while (fiber !== null) {
9468 var nextFiber = void 0;
9469 // Visit this fiber.
9470 switch (fiber.tag) {
9471 case ContextConsumer:
9472 // Check if the context matches.
9473 var observedBits = fiber.stateNode | 0;
9474 if (fiber.type === context && (observedBits & changedBits) !== 0) {
9475 // Update the expiration time of all the ancestors, including
9476 // the alternates.
9477 var node = fiber;
9478 while (node !== null) {
9479 var alternate = node.alternate;
9480 if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) {
9481 node.expirationTime = renderExpirationTime;
9482 if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
9483 alternate.expirationTime = renderExpirationTime;
9484 }
9485 } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
9486 alternate.expirationTime = renderExpirationTime;
9487 } else {
9488 // Neither alternate was updated, which means the rest of the
9489 // ancestor path already has sufficient priority.
9490 break;
9491 }
9492 node = node['return'];
9493 }
9494 // Don't scan deeper than a matching consumer. When we render the
9495 // consumer, we'll continue scanning from that point. This way the
9496 // scanning work is time-sliced.
9497 nextFiber = null;
9498 } else {
9499 // Traverse down.
9500 nextFiber = fiber.child;
9501 }
9502 break;
9503 case ContextProvider:
9504 // Don't scan deeper if this is a matching provider
9505 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
9506 break;
9507 default:
9508 // Traverse down.
9509 nextFiber = fiber.child;
9510 break;
9511 }
9512 if (nextFiber !== null) {
9513 // Set the return pointer of the child to the work-in-progress fiber.
9514 nextFiber['return'] = fiber;
9515 } else {
9516 // No child. Traverse to next sibling.
9517 nextFiber = fiber;
9518 while (nextFiber !== null) {

Callers 2

updateContextProviderFunction · 0.70
updateContextConsumerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected