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

Function updateContextProvider

code/third-party/public/app.js:9537–9610  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9535 }
9536
9537 function updateContextProvider(current, workInProgress, renderExpirationTime) {
9538 var providerType = workInProgress.type;
9539 var context = providerType.context;
9540
9541 var newProps = workInProgress.pendingProps;
9542 var oldProps = workInProgress.memoizedProps;
9543
9544 if (hasLegacyContextChanged()) {
9545 // Normally we can bail out on props equality but if context has changed
9546 // we don't do the bailout and we have to reuse existing props instead.
9547 } else if (oldProps === newProps) {
9548 workInProgress.stateNode = 0;
9549 pushProvider(workInProgress);
9550 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9551 }
9552
9553 var newValue = newProps.value;
9554 workInProgress.memoizedProps = newProps;
9555
9556 var changedBits = void 0;
9557 if (oldProps === null) {
9558 // Initial render
9559 changedBits = MAX_SIGNED_31_BIT_INT;
9560 } else {
9561 if (oldProps.value === newProps.value) {
9562 // No change. Bailout early if children are the same.
9563 if (oldProps.children === newProps.children) {
9564 workInProgress.stateNode = 0;
9565 pushProvider(workInProgress);
9566 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9567 }
9568 changedBits = 0;
9569 } else {
9570 var oldValue = oldProps.value;
9571 // Use Object.is to compare the new context value to the old value.
9572 // Inlined Object.is polyfill.
9573 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
9574 if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare
9575 ) {
9576 // No change. Bailout early if children are the same.
9577 if (oldProps.children === newProps.children) {
9578 workInProgress.stateNode = 0;
9579 pushProvider(workInProgress);
9580 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9581 }
9582 changedBits = 0;
9583 } else {
9584 changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
9585 {
9586 warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
9587 }
9588 changedBits |= 0;
9589
9590 if (changedBits === 0) {
9591 // No change. Bailout early if children are the same.
9592 if (oldProps.children === newProps.children) {
9593 workInProgress.stateNode = 0;
9594 pushProvider(workInProgress);

Callers 1

beginWorkFunction · 0.70

Calls 5

warningFunction · 0.85
pushProviderFunction · 0.70
propagateContextChangeFunction · 0.70
reconcileChildrenFunction · 0.70

Tested by

no test coverage detected