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

Function finishClassComponent

code/event-handlers/public/app.js:9221–9281  ·  view source on GitHub ↗
(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime)

Source from the content-addressed store, hash-verified

9219 }
9220
9221 function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime) {
9222 // Refs should update even if shouldComponentUpdate returns false
9223 markRef(current, workInProgress);
9224
9225 if (!shouldUpdate && !didCaptureError) {
9226 // Context providers should defer to sCU for rendering
9227 if (hasContext) {
9228 invalidateContextProvider(workInProgress, false);
9229 }
9230
9231 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9232 }
9233
9234 var ctor = workInProgress.type;
9235 var instance = workInProgress.stateNode;
9236
9237 // Rerender
9238 ReactCurrentOwner.current = workInProgress;
9239 var nextChildren = void 0;
9240 if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) {
9241 // If we captured an error, but getDerivedStateFrom catch is not defined,
9242 // unmount all the children. componentDidCatch will schedule an update to
9243 // re-render a fallback. This is temporary until we migrate everyone to
9244 // the new API.
9245 // TODO: Warn in a future release.
9246 nextChildren = null;
9247 } else {
9248 {
9249 ReactDebugCurrentFiber.setCurrentPhase('render');
9250 nextChildren = instance.render();
9251 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
9252 instance.render();
9253 }
9254 ReactDebugCurrentFiber.setCurrentPhase(null);
9255 }
9256 }
9257
9258 // React DevTools reads this flag.
9259 workInProgress.effectTag |= PerformedWork;
9260 if (didCaptureError) {
9261 // If we're recovering from an error, reconcile twice: first to delete
9262 // all the existing children.
9263 reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime);
9264 workInProgress.child = null;
9265 // Now we can continue reconciling like normal. This has the effect of
9266 // remounting all children regardless of whether their their
9267 // identity matches.
9268 }
9269 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime);
9270 // Memoize props and state using the values we just used to render.
9271 // TODO: Restructure so we never read values from the instance.
9272 memoizeState(workInProgress, instance.state);
9273 memoizeProps(workInProgress, instance.props);
9274
9275 // The context might have changed so we need to recalculate it.
9276 if (hasContext) {
9277 invalidateContextProvider(workInProgress, true);
9278 }

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