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

Function propagateContextChange

code/styling/public/app.js:10228–10302  ·  view source on GitHub ↗
(workInProgress, context, changedBits, renderExpirationTime)

Source from the content-addressed store, hash-verified

10226 }
10227
10228 function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
10229 var fiber = workInProgress.child;
10230 if (fiber !== null) {
10231 // Set the return pointer of the child to the work-in-progress fiber.
10232 fiber['return'] = workInProgress;
10233 }
10234 while (fiber !== null) {
10235 var nextFiber = void 0;
10236 // Visit this fiber.
10237 switch (fiber.tag) {
10238 case ContextConsumer:
10239 // Check if the context matches.
10240 var observedBits = fiber.stateNode | 0;
10241 if (fiber.type === context && (observedBits & changedBits) !== 0) {
10242 // Update the expiration time of all the ancestors, including
10243 // the alternates.
10244 var node = fiber;
10245 while (node !== null) {
10246 var alternate = node.alternate;
10247 if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) {
10248 node.expirationTime = renderExpirationTime;
10249 if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
10250 alternate.expirationTime = renderExpirationTime;
10251 }
10252 } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
10253 alternate.expirationTime = renderExpirationTime;
10254 } else {
10255 // Neither alternate was updated, which means the rest of the
10256 // ancestor path already has sufficient priority.
10257 break;
10258 }
10259 node = node['return'];
10260 }
10261 // Don't scan deeper than a matching consumer. When we render the
10262 // consumer, we'll continue scanning from that point. This way the
10263 // scanning work is time-sliced.
10264 nextFiber = null;
10265 } else {
10266 // Traverse down.
10267 nextFiber = fiber.child;
10268 }
10269 break;
10270 case ContextProvider:
10271 // Don't scan deeper if this is a matching provider
10272 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
10273 break;
10274 default:
10275 // Traverse down.
10276 nextFiber = fiber.child;
10277 break;
10278 }
10279 if (nextFiber !== null) {
10280 // Set the return pointer of the child to the work-in-progress fiber.
10281 nextFiber['return'] = fiber;
10282 } else {
10283 // No child. Traverse to next sibling.
10284 nextFiber = fiber;
10285 while (nextFiber !== null) {

Callers 2

updateContextProviderFunction · 0.70
updateContextConsumerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected