MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / updateContextProvider

Function updateContextProvider

code/event-handlers/public/app.js:9634–9707  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9632 }
9633
9634 function updateContextProvider(current, workInProgress, renderExpirationTime) {
9635 var providerType = workInProgress.type;
9636 var context = providerType.context;
9637
9638 var newProps = workInProgress.pendingProps;
9639 var oldProps = workInProgress.memoizedProps;
9640
9641 if (hasLegacyContextChanged()) {
9642 // Normally we can bail out on props equality but if context has changed
9643 // we don't do the bailout and we have to reuse existing props instead.
9644 } else if (oldProps === newProps) {
9645 workInProgress.stateNode = 0;
9646 pushProvider(workInProgress);
9647 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9648 }
9649
9650 var newValue = newProps.value;
9651 workInProgress.memoizedProps = newProps;
9652
9653 var changedBits = void 0;
9654 if (oldProps === null) {
9655 // Initial render
9656 changedBits = MAX_SIGNED_31_BIT_INT;
9657 } else {
9658 if (oldProps.value === newProps.value) {
9659 // No change. Bailout early if children are the same.
9660 if (oldProps.children === newProps.children) {
9661 workInProgress.stateNode = 0;
9662 pushProvider(workInProgress);
9663 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9664 }
9665 changedBits = 0;
9666 } else {
9667 var oldValue = oldProps.value;
9668 // Use Object.is to compare the new context value to the old value.
9669 // Inlined Object.is polyfill.
9670 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
9671 if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare
9672 ) {
9673 // No change. Bailout early if children are the same.
9674 if (oldProps.children === newProps.children) {
9675 workInProgress.stateNode = 0;
9676 pushProvider(workInProgress);
9677 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9678 }
9679 changedBits = 0;
9680 } else {
9681 changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
9682 {
9683 warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
9684 }
9685 changedBits |= 0;
9686
9687 if (changedBits === 0) {
9688 // No change. Bailout early if children are the same.
9689 if (oldProps.children === newProps.children) {
9690 workInProgress.stateNode = 0;
9691 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