MCPcopy
hub / github.com/krasimir/react-in-patterns / finishClassComponent

Function finishClassComponent

code/redux/public/app.js:10142–10202  ·  view source on GitHub ↗
(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime)

Source from the content-addressed store, hash-verified

10140 }
10141
10142 function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime) {
10143 // Refs should update even if shouldComponentUpdate returns false
10144 markRef(current, workInProgress);
10145
10146 if (!shouldUpdate && !didCaptureError) {
10147 // Context providers should defer to sCU for rendering
10148 if (hasContext) {
10149 invalidateContextProvider(workInProgress, false);
10150 }
10151
10152 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10153 }
10154
10155 var ctor = workInProgress.type;
10156 var instance = workInProgress.stateNode;
10157
10158 // Rerender
10159 ReactCurrentOwner.current = workInProgress;
10160 var nextChildren = void 0;
10161 if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) {
10162 // If we captured an error, but getDerivedStateFrom catch is not defined,
10163 // unmount all the children. componentDidCatch will schedule an update to
10164 // re-render a fallback. This is temporary until we migrate everyone to
10165 // the new API.
10166 // TODO: Warn in a future release.
10167 nextChildren = null;
10168 } else {
10169 {
10170 ReactDebugCurrentFiber.setCurrentPhase('render');
10171 nextChildren = instance.render();
10172 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
10173 instance.render();
10174 }
10175 ReactDebugCurrentFiber.setCurrentPhase(null);
10176 }
10177 }
10178
10179 // React DevTools reads this flag.
10180 workInProgress.effectTag |= PerformedWork;
10181 if (didCaptureError) {
10182 // If we're recovering from an error, reconcile twice: first to delete
10183 // all the existing children.
10184 reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime);
10185 workInProgress.child = null;
10186 // Now we can continue reconciling like normal. This has the effect of
10187 // remounting all children regardless of whether their their
10188 // identity matches.
10189 }
10190 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime);
10191 // Memoize props and state using the values we just used to render.
10192 // TODO: Restructure so we never read values from the instance.
10193 memoizeState(workInProgress, instance.state);
10194 memoizeProps(workInProgress, instance.props);
10195
10196 // The context might have changed so we need to recalculate it.
10197 if (hasContext) {
10198 invalidateContextProvider(workInProgress, true);
10199 }

Callers 2

updateClassComponentFunction · 0.70

Calls 7

markRefFunction · 0.70
memoizeStateFunction · 0.70
memoizePropsFunction · 0.70
renderMethod · 0.45

Tested by

no test coverage detected