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

Function updateClassInstance

code/composition/public/app.js:8810–8925  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

8808
8809 // Invokes the update life-cycles and returns false if it shouldn't rerender.
8810 function updateClassInstance(current, workInProgress, renderExpirationTime) {
8811 var ctor = workInProgress.type;
8812 var instance = workInProgress.stateNode;
8813 resetInputPointers(workInProgress, instance);
8814
8815 var oldProps = workInProgress.memoizedProps;
8816 var newProps = workInProgress.pendingProps;
8817 var oldContext = instance.context;
8818 var newUnmaskedContext = getUnmaskedContext(workInProgress);
8819 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
8820
8821 // Note: During these life-cycles, instance.props/instance.state are what
8822 // ever the previously attempted to render - not the "current". However,
8823 // during componentDidUpdate we pass the "current" props.
8824
8825 // In order to support react-lifecycles-compat polyfilled components,
8826 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
8827 if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
8828 if (oldProps !== newProps || oldContext !== newContext) {
8829 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
8830 }
8831 }
8832
8833 // Compute the next state using the memoized state and the update queue.
8834 var oldState = workInProgress.memoizedState;
8835 // TODO: Previous state can be null.
8836 var newState = void 0;
8837 var derivedStateFromCatch = void 0;
8838 if (workInProgress.updateQueue !== null) {
8839 newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
8840
8841 var updateQueue = workInProgress.updateQueue;
8842 if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
8843 var capturedValues = updateQueue.capturedValues;
8844 // Don't remove these from the update queue yet. We need them in
8845 // finishClassComponent. Do the reset there.
8846 // TODO: This is awkward. Refactor class components.
8847 // updateQueue.capturedValues = null;
8848 derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
8849 }
8850 } else {
8851 newState = oldState;
8852 }
8853
8854 var derivedStateFromProps = void 0;
8855 if (oldProps !== newProps) {
8856 // The prevState parameter should be the partially updated state.
8857 // Otherwise, spreading state in return values could override updates.
8858 derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
8859 }
8860
8861 if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
8862 // Render-phase updates (like this) should not be added to the update queue,
8863 // So that multiple render passes do not enqueue multiple updates.
8864 // Instead, just synchronously merge the returned state into the instance.
8865 newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
8866 }
8867 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