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

Function finishClassComponent

code/new-context-api/public/app.js:9252–9312  ·  view source on GitHub ↗
(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime)

Source from the content-addressed store, hash-verified

9250 }
9251
9252 function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime) {
9253 // Refs should update even if shouldComponentUpdate returns false
9254 markRef(current, workInProgress);
9255
9256 if (!shouldUpdate && !didCaptureError) {
9257 // Context providers should defer to sCU for rendering
9258 if (hasContext) {
9259 invalidateContextProvider(workInProgress, false);
9260 }
9261
9262 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9263 }
9264
9265 var ctor = workInProgress.type;
9266 var instance = workInProgress.stateNode;
9267
9268 // Rerender
9269 ReactCurrentOwner.current = workInProgress;
9270 var nextChildren = void 0;
9271 if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) {
9272 // If we captured an error, but getDerivedStateFrom catch is not defined,
9273 // unmount all the children. componentDidCatch will schedule an update to
9274 // re-render a fallback. This is temporary until we migrate everyone to
9275 // the new API.
9276 // TODO: Warn in a future release.
9277 nextChildren = null;
9278 } else {
9279 {
9280 ReactDebugCurrentFiber.setCurrentPhase('render');
9281 nextChildren = instance.render();
9282 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
9283 instance.render();
9284 }
9285 ReactDebugCurrentFiber.setCurrentPhase(null);
9286 }
9287 }
9288
9289 // React DevTools reads this flag.
9290 workInProgress.effectTag |= PerformedWork;
9291 if (didCaptureError) {
9292 // If we're recovering from an error, reconcile twice: first to delete
9293 // all the existing children.
9294 reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime);
9295 workInProgress.child = null;
9296 // Now we can continue reconciling like normal. This has the effect of
9297 // remounting all children regardless of whether their their
9298 // identity matches.
9299 }
9300 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime);
9301 // Memoize props and state using the values we just used to render.
9302 // TODO: Restructure so we never read values from the instance.
9303 memoizeState(workInProgress, instance.state);
9304 memoizeProps(workInProgress, instance.props);
9305
9306 // The context might have changed so we need to recalculate it.
9307 if (hasContext) {
9308 invalidateContextProvider(workInProgress, true);
9309 }

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