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

Function updateClassInstance

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

Source from the content-addressed store, hash-verified

7903
7904 // Invokes the update life-cycles and returns false if it shouldn't rerender.
7905 function updateClassInstance(current, workInProgress, renderExpirationTime) {
7906 var ctor = workInProgress.type;
7907 var instance = workInProgress.stateNode;
7908 resetInputPointers(workInProgress, instance);
7909
7910 var oldProps = workInProgress.memoizedProps;
7911 var newProps = workInProgress.pendingProps;
7912 var oldContext = instance.context;
7913 var newUnmaskedContext = getUnmaskedContext(workInProgress);
7914 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
7915
7916 // Note: During these life-cycles, instance.props/instance.state are what
7917 // ever the previously attempted to render - not the "current". However,
7918 // during componentDidUpdate we pass the "current" props.
7919
7920 // In order to support react-lifecycles-compat polyfilled components,
7921 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
7922 if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
7923 if (oldProps !== newProps || oldContext !== newContext) {
7924 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
7925 }
7926 }
7927
7928 // Compute the next state using the memoized state and the update queue.
7929 var oldState = workInProgress.memoizedState;
7930 // TODO: Previous state can be null.
7931 var newState = void 0;
7932 var derivedStateFromCatch = void 0;
7933 if (workInProgress.updateQueue !== null) {
7934 newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
7935
7936 var updateQueue = workInProgress.updateQueue;
7937 if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
7938 var capturedValues = updateQueue.capturedValues;
7939 // Don't remove these from the update queue yet. We need them in
7940 // finishClassComponent. Do the reset there.
7941 // TODO: This is awkward. Refactor class components.
7942 // updateQueue.capturedValues = null;
7943 derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
7944 }
7945 } else {
7946 newState = oldState;
7947 }
7948
7949 var derivedStateFromProps = void 0;
7950 if (oldProps !== newProps) {
7951 // The prevState parameter should be the partially updated state.
7952 // Otherwise, spreading state in return values could override updates.
7953 derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
7954 }
7955
7956 if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
7957 // Render-phase updates (like this) should not be added to the update queue,
7958 // So that multiple render passes do not enqueue multiple updates.
7959 // Instead, just synchronously merge the returned state into the instance.
7960 newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
7961 }
7962 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