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

Function finishClassComponent

code/communication/public/app.js:9926–9986  ·  view source on GitHub ↗
(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime)

Source from the content-addressed store, hash-verified

9924 }
9925
9926 function finishClassComponent(current, workInProgress, shouldUpdate, hasContext, didCaptureError, renderExpirationTime) {
9927 // Refs should update even if shouldComponentUpdate returns false
9928 markRef(current, workInProgress);
9929
9930 if (!shouldUpdate && !didCaptureError) {
9931 // Context providers should defer to sCU for rendering
9932 if (hasContext) {
9933 invalidateContextProvider(workInProgress, false);
9934 }
9935
9936 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9937 }
9938
9939 var ctor = workInProgress.type;
9940 var instance = workInProgress.stateNode;
9941
9942 // Rerender
9943 ReactCurrentOwner.current = workInProgress;
9944 var nextChildren = void 0;
9945 if (didCaptureError && (!enableGetDerivedStateFromCatch || typeof ctor.getDerivedStateFromCatch !== 'function')) {
9946 // If we captured an error, but getDerivedStateFrom catch is not defined,
9947 // unmount all the children. componentDidCatch will schedule an update to
9948 // re-render a fallback. This is temporary until we migrate everyone to
9949 // the new API.
9950 // TODO: Warn in a future release.
9951 nextChildren = null;
9952 } else {
9953 {
9954 ReactDebugCurrentFiber.setCurrentPhase('render');
9955 nextChildren = instance.render();
9956 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
9957 instance.render();
9958 }
9959 ReactDebugCurrentFiber.setCurrentPhase(null);
9960 }
9961 }
9962
9963 // React DevTools reads this flag.
9964 workInProgress.effectTag |= PerformedWork;
9965 if (didCaptureError) {
9966 // If we're recovering from an error, reconcile twice: first to delete
9967 // all the existing children.
9968 reconcileChildrenAtExpirationTime(current, workInProgress, null, renderExpirationTime);
9969 workInProgress.child = null;
9970 // Now we can continue reconciling like normal. This has the effect of
9971 // remounting all children regardless of whether their their
9972 // identity matches.
9973 }
9974 reconcileChildrenAtExpirationTime(current, workInProgress, nextChildren, renderExpirationTime);
9975 // Memoize props and state using the values we just used to render.
9976 // TODO: Restructure so we never read values from the instance.
9977 memoizeState(workInProgress, instance.state);
9978 memoizeProps(workInProgress, instance.props);
9979
9980 // The context might have changed so we need to recalculate it.
9981 if (hasContext) {
9982 invalidateContextProvider(workInProgress, true);
9983 }

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