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

Function updateContextProvider

code/redux/public/app.js:10555–10628  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10553 }
10554
10555 function updateContextProvider(current, workInProgress, renderExpirationTime) {
10556 var providerType = workInProgress.type;
10557 var context = providerType.context;
10558
10559 var newProps = workInProgress.pendingProps;
10560 var oldProps = workInProgress.memoizedProps;
10561
10562 if (hasLegacyContextChanged()) {
10563 // Normally we can bail out on props equality but if context has changed
10564 // we don't do the bailout and we have to reuse existing props instead.
10565 } else if (oldProps === newProps) {
10566 workInProgress.stateNode = 0;
10567 pushProvider(workInProgress);
10568 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10569 }
10570
10571 var newValue = newProps.value;
10572 workInProgress.memoizedProps = newProps;
10573
10574 var changedBits = void 0;
10575 if (oldProps === null) {
10576 // Initial render
10577 changedBits = MAX_SIGNED_31_BIT_INT;
10578 } else {
10579 if (oldProps.value === newProps.value) {
10580 // No change. Bailout early if children are the same.
10581 if (oldProps.children === newProps.children) {
10582 workInProgress.stateNode = 0;
10583 pushProvider(workInProgress);
10584 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10585 }
10586 changedBits = 0;
10587 } else {
10588 var oldValue = oldProps.value;
10589 // Use Object.is to compare the new context value to the old value.
10590 // Inlined Object.is polyfill.
10591 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
10592 if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare
10593 ) {
10594 // No change. Bailout early if children are the same.
10595 if (oldProps.children === newProps.children) {
10596 workInProgress.stateNode = 0;
10597 pushProvider(workInProgress);
10598 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10599 }
10600 changedBits = 0;
10601 } else {
10602 changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
10603 {
10604 warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
10605 }
10606 changedBits |= 0;
10607
10608 if (changedBits === 0) {
10609 // No change. Bailout early if children are the same.
10610 if (oldProps.children === newProps.children) {
10611 workInProgress.stateNode = 0;
10612 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