MCPcopy Create free account
hub / github.com/reactjs/react-rails / finishClassComponent

Function finishClassComponent

lib/assets/react-source/development/react.js:20822–20887  ·  view source on GitHub ↗
(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime)

Source from the content-addressed store, hash-verified

20820 }
20821
20822 function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
20823 // Refs should update even if shouldComponentUpdate returns false
20824 markRef(current, workInProgress);
20825 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
20826
20827 if (!shouldUpdate && !didCaptureError) {
20828 // Context providers should defer to sCU for rendering
20829 if (hasContext) {
20830 invalidateContextProvider(workInProgress, Component, false);
20831 }
20832
20833 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
20834 }
20835
20836 var instance = workInProgress.stateNode; // Rerender
20837
20838 ReactCurrentOwner$1.current = workInProgress;
20839 var nextChildren;
20840
20841 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
20842 // If we captured an error, but getDerivedStateFromError is not defined,
20843 // unmount all the children. componentDidCatch will schedule an update to
20844 // re-render a fallback. This is temporary until we migrate everyone to
20845 // the new API.
20846 // TODO: Warn in a future release.
20847 nextChildren = null;
20848
20849 {
20850 stopProfilerTimerIfRunning();
20851 }
20852 } else {
20853 {
20854 setIsRendering(true);
20855 nextChildren = instance.render();
20856
20857 if ( workInProgress.mode & StrictMode) {
20858 instance.render();
20859 }
20860
20861 setIsRendering(false);
20862 }
20863 } // React DevTools reads this flag.
20864
20865
20866 workInProgress.effectTag |= PerformedWork;
20867
20868 if (current !== null && didCaptureError) {
20869 // If we're recovering from an error, reconcile without reusing any of
20870 // the existing children. Conceptually, the normal children and the children
20871 // that are shown on error are two different sets, so we shouldn't reuse
20872 // normal children even if their identities match.
20873 forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderExpirationTime);
20874 } else {
20875 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
20876 } // Memoize state using the values we just used to render.
20877 // TODO: Restructure so we never read values from the instance.
20878
20879

Callers 3

updateClassComponentFunction · 0.85

Calls 8

markRefFunction · 0.85
setIsRenderingFunction · 0.85
reconcileChildrenFunction · 0.85
renderMethod · 0.80

Tested by

no test coverage detected