MCPcopy Create free account
hub / github.com/reactjs/react-rails / propagateContextChange

Function propagateContextChange

lib/assets/react-source/development/react.js:15665–15758  ·  view source on GitHub ↗
(workInProgress, context, changedBits, renderExpirationTime)

Source from the content-addressed store, hash-verified

15663 }
15664 }
15665 function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
15666 var fiber = workInProgress.child;
15667
15668 if (fiber !== null) {
15669 // Set the return pointer of the child to the work-in-progress fiber.
15670 fiber.return = workInProgress;
15671 }
15672
15673 while (fiber !== null) {
15674 var nextFiber = void 0; // Visit this fiber.
15675
15676 var list = fiber.dependencies;
15677
15678 if (list !== null) {
15679 nextFiber = fiber.child;
15680 var dependency = list.firstContext;
15681
15682 while (dependency !== null) {
15683 // Check if the context matches.
15684 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
15685 // Match! Schedule an update on this fiber.
15686 if (fiber.tag === ClassComponent) {
15687 // Schedule a force update on the work-in-progress.
15688 var update = createUpdate(renderExpirationTime, null);
15689 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
15690 // update to the current fiber, too, which means it will persist even if
15691 // this render is thrown away. Since it's a race condition, not sure it's
15692 // worth fixing.
15693
15694 enqueueUpdate(fiber, update);
15695 }
15696
15697 if (fiber.expirationTime < renderExpirationTime) {
15698 fiber.expirationTime = renderExpirationTime;
15699 }
15700
15701 var alternate = fiber.alternate;
15702
15703 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
15704 alternate.expirationTime = renderExpirationTime;
15705 }
15706
15707 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
15708
15709 if (list.expirationTime < renderExpirationTime) {
15710 list.expirationTime = renderExpirationTime;
15711 } // Since we already found a match, we can stop traversing the
15712 // dependency list.
15713
15714
15715 break;
15716 }
15717
15718 dependency = dependency.next;
15719 }
15720 } else if (fiber.tag === ContextProvider) {
15721 // Don't scan deeper if this is a matching provider
15722 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;

Callers 1

updateContextProviderFunction · 0.85

Calls 3

createUpdateFunction · 0.85
enqueueUpdateFunction · 0.85
scheduleWorkOnParentPathFunction · 0.85

Tested by

no test coverage detected