MCPcopy
hub / github.com/facebook/react / finishClassComponent

Function finishClassComponent

packages/react-reconciler/src/ReactFiberBeginWork.js:1689–1781  ·  view source on GitHub ↗
(
  current: Fiber | null,
  workInProgress: Fiber,
  Component: any,
  shouldUpdate: boolean,
  hasContext: boolean,
  renderLanes: Lanes,
)

Source from the content-addressed store, hash-verified

1687}
1688
1689function finishClassComponent(
1690 current: Fiber | null,
1691 workInProgress: Fiber,
1692 Component: any,
1693 shouldUpdate: boolean,
1694 hasContext: boolean,
1695 renderLanes: Lanes,
1696) {
1697 // Refs should update even if shouldComponentUpdate returns false
1698 markRef(current, workInProgress);
1699
1700 const didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
1701
1702 if (!shouldUpdate && !didCaptureError) {
1703 // Context providers should defer to sCU for rendering
1704 if (hasContext) {
1705 invalidateContextProvider(workInProgress, Component, false);
1706 }
1707
1708 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
1709 }
1710
1711 const instance = workInProgress.stateNode;
1712
1713 // Rerender
1714 if (__DEV__) {
1715 setCurrentFiber(workInProgress);
1716 }
1717 let nextChildren;
1718 if (
1719 didCaptureError &&
1720 typeof Component.getDerivedStateFromError !== 'function'
1721 ) {
1722 // If we captured an error, but getDerivedStateFromError is not defined,
1723 // unmount all the children. componentDidCatch will schedule an update to
1724 // re-render a fallback. This is temporary until we migrate everyone to
1725 // the new API.
1726 // TODO: Warn in a future release.
1727 nextChildren = null;
1728
1729 if (enableProfilerTimer) {
1730 stopProfilerTimerIfRunning(workInProgress);
1731 }
1732 } else {
1733 if (enableSchedulingProfiler) {
1734 markComponentRenderStarted(workInProgress);
1735 }
1736 if (__DEV__) {
1737 nextChildren = callRenderInDEV(instance);
1738 if (workInProgress.mode & StrictLegacyMode) {
1739 setIsStrictModeForDevtools(true);
1740 try {
1741 callRenderInDEV(instance);
1742 } finally {
1743 setIsStrictModeForDevtools(false);
1744 }
1745 }
1746 } else {

Callers 2

updateClassComponentFunction · 0.70

Calls 11

setCurrentFiberFunction · 0.90
markRefFunction · 0.85
reconcileChildrenFunction · 0.85
renderMethod · 0.65

Tested by

no test coverage detected