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

Function updateClassInstance

code/new-context-api/public/app.js:8033–8148  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

8031
8032 // Invokes the update life-cycles and returns false if it shouldn't rerender.
8033 function updateClassInstance(current, workInProgress, renderExpirationTime) {
8034 var ctor = workInProgress.type;
8035 var instance = workInProgress.stateNode;
8036 resetInputPointers(workInProgress, instance);
8037
8038 var oldProps = workInProgress.memoizedProps;
8039 var newProps = workInProgress.pendingProps;
8040 var oldContext = instance.context;
8041 var newUnmaskedContext = getUnmaskedContext(workInProgress);
8042 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
8043
8044 // Note: During these life-cycles, instance.props/instance.state are what
8045 // ever the previously attempted to render - not the "current". However,
8046 // during componentDidUpdate we pass the "current" props.
8047
8048 // In order to support react-lifecycles-compat polyfilled components,
8049 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
8050 if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') {
8051 if (oldProps !== newProps || oldContext !== newContext) {
8052 callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
8053 }
8054 }
8055
8056 // Compute the next state using the memoized state and the update queue.
8057 var oldState = workInProgress.memoizedState;
8058 // TODO: Previous state can be null.
8059 var newState = void 0;
8060 var derivedStateFromCatch = void 0;
8061 if (workInProgress.updateQueue !== null) {
8062 newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
8063
8064 var updateQueue = workInProgress.updateQueue;
8065 if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
8066 var capturedValues = updateQueue.capturedValues;
8067 // Don't remove these from the update queue yet. We need them in
8068 // finishClassComponent. Do the reset there.
8069 // TODO: This is awkward. Refactor class components.
8070 // updateQueue.capturedValues = null;
8071 derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
8072 }
8073 } else {
8074 newState = oldState;
8075 }
8076
8077 var derivedStateFromProps = void 0;
8078 if (oldProps !== newProps) {
8079 // The prevState parameter should be the partially updated state.
8080 // Otherwise, spreading state in return values could override updates.
8081 derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
8082 }
8083
8084 if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
8085 // Render-phase updates (like this) should not be added to the update queue,
8086 // So that multiple render passes do not enqueue multiple updates.
8087 // Instead, just synchronously merge the returned state into the instance.
8088 newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
8089 }
8090 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