MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / propagateContextChange

Function propagateContextChange

code/new-context-api/public/app.js:9589–9663  ·  view source on GitHub ↗
(workInProgress, context, changedBits, renderExpirationTime)

Source from the content-addressed store, hash-verified

9587 }
9588
9589 function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
9590 var fiber = workInProgress.child;
9591 if (fiber !== null) {
9592 // Set the return pointer of the child to the work-in-progress fiber.
9593 fiber['return'] = workInProgress;
9594 }
9595 while (fiber !== null) {
9596 var nextFiber = void 0;
9597 // Visit this fiber.
9598 switch (fiber.tag) {
9599 case ContextConsumer:
9600 // Check if the context matches.
9601 var observedBits = fiber.stateNode | 0;
9602 if (fiber.type === context && (observedBits & changedBits) !== 0) {
9603 // Update the expiration time of all the ancestors, including
9604 // the alternates.
9605 var node = fiber;
9606 while (node !== null) {
9607 var alternate = node.alternate;
9608 if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) {
9609 node.expirationTime = renderExpirationTime;
9610 if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
9611 alternate.expirationTime = renderExpirationTime;
9612 }
9613 } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
9614 alternate.expirationTime = renderExpirationTime;
9615 } else {
9616 // Neither alternate was updated, which means the rest of the
9617 // ancestor path already has sufficient priority.
9618 break;
9619 }
9620 node = node['return'];
9621 }
9622 // Don't scan deeper than a matching consumer. When we render the
9623 // consumer, we'll continue scanning from that point. This way the
9624 // scanning work is time-sliced.
9625 nextFiber = null;
9626 } else {
9627 // Traverse down.
9628 nextFiber = fiber.child;
9629 }
9630 break;
9631 case ContextProvider:
9632 // Don't scan deeper if this is a matching provider
9633 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
9634 break;
9635 default:
9636 // Traverse down.
9637 nextFiber = fiber.child;
9638 break;
9639 }
9640 if (nextFiber !== null) {
9641 // Set the return pointer of the child to the work-in-progress fiber.
9642 nextFiber['return'] = fiber;
9643 } else {
9644 // No child. Traverse to next sibling.
9645 nextFiber = fiber;
9646 while (nextFiber !== null) {

Callers 2

updateContextProviderFunction · 0.70
updateContextConsumerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected