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

Function propagateContextChange

code/communication/public/app.js:10263–10337  ·  view source on GitHub ↗
(workInProgress, context, changedBits, renderExpirationTime)

Source from the content-addressed store, hash-verified

10261 }
10262
10263 function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
10264 var fiber = workInProgress.child;
10265 if (fiber !== null) {
10266 // Set the return pointer of the child to the work-in-progress fiber.
10267 fiber['return'] = workInProgress;
10268 }
10269 while (fiber !== null) {
10270 var nextFiber = void 0;
10271 // Visit this fiber.
10272 switch (fiber.tag) {
10273 case ContextConsumer:
10274 // Check if the context matches.
10275 var observedBits = fiber.stateNode | 0;
10276 if (fiber.type === context && (observedBits & changedBits) !== 0) {
10277 // Update the expiration time of all the ancestors, including
10278 // the alternates.
10279 var node = fiber;
10280 while (node !== null) {
10281 var alternate = node.alternate;
10282 if (node.expirationTime === NoWork || node.expirationTime > renderExpirationTime) {
10283 node.expirationTime = renderExpirationTime;
10284 if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
10285 alternate.expirationTime = renderExpirationTime;
10286 }
10287 } else if (alternate !== null && (alternate.expirationTime === NoWork || alternate.expirationTime > renderExpirationTime)) {
10288 alternate.expirationTime = renderExpirationTime;
10289 } else {
10290 // Neither alternate was updated, which means the rest of the
10291 // ancestor path already has sufficient priority.
10292 break;
10293 }
10294 node = node['return'];
10295 }
10296 // Don't scan deeper than a matching consumer. When we render the
10297 // consumer, we'll continue scanning from that point. This way the
10298 // scanning work is time-sliced.
10299 nextFiber = null;
10300 } else {
10301 // Traverse down.
10302 nextFiber = fiber.child;
10303 }
10304 break;
10305 case ContextProvider:
10306 // Don't scan deeper if this is a matching provider
10307 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
10308 break;
10309 default:
10310 // Traverse down.
10311 nextFiber = fiber.child;
10312 break;
10313 }
10314 if (nextFiber !== null) {
10315 // Set the return pointer of the child to the work-in-progress fiber.
10316 nextFiber['return'] = fiber;
10317 } else {
10318 // No child. Traverse to next sibling.
10319 nextFiber = fiber;
10320 while (nextFiber !== null) {

Callers 2

updateContextProviderFunction · 0.70
updateContextConsumerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected