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

Function updateClassInstance

code/styling/public/app.js:8672–8787  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

8670
8671 // Invokes the update life-cycles and returns false if it shouldn't rerender.
8672 function updateClassInstance(current, workInProgress, renderExpirationTime) {
8673 var ctor = workInProgress.type;
8674 var instance = workInProgress.stateNode;
8675 resetInputPointers(workInProgress, instance);
8676
8677 var oldProps = workInProgress.memoizedProps;
8678 var newProps = workInProgress.pendingProps;
8679 var oldContext = instance.context;
8680 var newUnmaskedContext = getUnmaskedContext(workInProgress);
8681 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
8682
8683 // Note: During these life-cycles, instance.props/instance.state are what
8684 // ever the previously attempted to render - not the "current". However,
8685 // during componentDidUpdate we pass the "current" props.
8686
8687 // In order to support react-lifecycles-compat polyfilled components,
8688 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
8689 if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
8690 if (oldProps !== newProps || oldContext !== newContext) {
8691 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
8692 }
8693 }
8694
8695 // Compute the next state using the memoized state and the update queue.
8696 var oldState = workInProgress.memoizedState;
8697 // TODO: Previous state can be null.
8698 var newState = void 0;
8699 var derivedStateFromCatch = void 0;
8700 if (workInProgress.updateQueue !== null) {
8701 newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
8702
8703 var updateQueue = workInProgress.updateQueue;
8704 if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
8705 var capturedValues = updateQueue.capturedValues;
8706 // Don't remove these from the update queue yet. We need them in
8707 // finishClassComponent. Do the reset there.
8708 // TODO: This is awkward. Refactor class components.
8709 // updateQueue.capturedValues = null;
8710 derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
8711 }
8712 } else {
8713 newState = oldState;
8714 }
8715
8716 var derivedStateFromProps = void 0;
8717 if (oldProps !== newProps) {
8718 // The prevState parameter should be the partially updated state.
8719 // Otherwise, spreading state in return values could override updates.
8720 derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
8721 }
8722
8723 if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
8724 // Render-phase updates (like this) should not be added to the update queue,
8725 // So that multiple render passes do not enqueue multiple updates.
8726 // Instead, just synchronously merge the returned state into the instance.
8727 newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
8728 }
8729 if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {

Callers 1

updateClassComponentFunction · 0.70

Calls 13

resetInputPointersFunction · 0.70
getUnmaskedContextFunction · 0.70
getMaskedContextFunction · 0.70
processUpdateQueueFunction · 0.70
hasContextChangedFunction · 0.70
startPhaseTimerFunction · 0.70
stopPhaseTimerFunction · 0.70
memoizePropsFunction · 0.70

Tested by

no test coverage detected