Home / Function/ updateFunctionComponent() — react Function Reference

updateFunctionComponent() — react Function Reference

Architecture documentation for the updateFunctionComponent() function in ReactFiberBeginWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  50e17875_d138_1098_df3a_5e5668c9be3d["updateFunctionComponent()"]
  0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|defined in| 0be70812_cc0c_b210_f84f_8e61dd5f831c
  d5867db8_c86c_35f1_776d_f9f063826e18["updateSimpleMemoComponent()"]
  d5867db8_c86c_35f1_776d_f9f063826e18 -->|calls| 50e17875_d138_1098_df3a_5e5668c9be3d
  00a9caf0_34fa_f3b2_0df5_823e58b3a1e6["mountIncompleteFunctionComponent()"]
  00a9caf0_34fa_f3b2_0df5_823e58b3a1e6 -->|calls| 50e17875_d138_1098_df3a_5e5668c9be3d
  53f55fda_e2b6_2801_4fbc_525f8828d23d["updateHostRoot()"]
  53f55fda_e2b6_2801_4fbc_525f8828d23d -->|calls| 50e17875_d138_1098_df3a_5e5668c9be3d
  235e1db1_02a4_912f_7d82_ea6636c850c0["beginWork()"]
  235e1db1_02a4_912f_7d82_ea6636c850c0 -->|calls| 50e17875_d138_1098_df3a_5e5668c9be3d
  e97df9a2_1803_92a2_50c0_f4ba3f1bebaa["validateFunctionComponentInDev()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| e97df9a2_1803_92a2_50c0_f4ba3f1bebaa
  1df0dd5b_17c8_c98c_3521_17154496ef7a["markComponentRenderStarted()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| 1df0dd5b_17c8_c98c_3521_17154496ef7a
  c88117c7_b46d_b4e4_536c_462d4e08c01e["markComponentRenderStopped()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| c88117c7_b46d_b4e4_536c_462d4e08c01e
  6cb202e6_76dc_0479_ff31_d0ef23610882["bailoutOnAlreadyFinishedWork()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| 6cb202e6_76dc_0479_ff31_d0ef23610882
  dae8f65a_04a5_194b_7c97_c4819e519207["getIsHydrating()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| dae8f65a_04a5_194b_7c97_c4819e519207
  cf5641cc_b89e_d6b2_5d40_41ad5bbdd682["reconcileChildren()"]
  50e17875_d138_1098_df3a_5e5668c9be3d -->|calls| cf5641cc_b89e_d6b2_5d40_41ad5bbdd682
  style 50e17875_d138_1098_df3a_5e5668c9be3d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberBeginWork.js lines 1422–1531

function updateFunctionComponent(
  current: null | Fiber,
  workInProgress: Fiber,
  Component: any,
  nextProps: any,
  renderLanes: Lanes,
) {
  if (__DEV__) {
    if (
      Component.prototype &&
      typeof Component.prototype.render === 'function'
    ) {
      const componentName = getComponentNameFromType(Component) || 'Unknown';

      if (!didWarnAboutBadClass[componentName]) {
        console.error(
          "The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
            'This is likely to cause errors. Change %s to extend React.Component instead.',
          componentName,
          componentName,
        );
        didWarnAboutBadClass[componentName] = true;
      }
    }

    if (workInProgress.mode & StrictLegacyMode) {
      ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
    }

    if (current === null) {
      // Some validations were previously done in mountIndeterminateComponent however and are now run
      // in updateFuntionComponent but only on mount
      validateFunctionComponentInDev(workInProgress, workInProgress.type);

      if (Component.contextTypes) {
        const componentName = getComponentNameFromType(Component) || 'Unknown';

        if (!didWarnAboutContextTypes[componentName]) {
          didWarnAboutContextTypes[componentName] = true;
          if (disableLegacyContext) {
            console.error(
              '%s uses the legacy contextTypes API which was removed in React 19. ' +
                'Use React.createContext() with React.useContext() instead. ' +
                '(https://react.dev/link/legacy-context)',
              componentName,
            );
          } else {
            console.error(
              '%s uses the legacy contextTypes API which will be removed soon. ' +
                'Use React.createContext() with React.useContext() instead. ' +
                '(https://react.dev/link/legacy-context)',
              componentName,
            );
          }
        }
      }
    }
  }

  let context;
  if (!disableLegacyContext && !disableLegacyContextForFunctionComponents) {
    const unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
    context = getMaskedContext(workInProgress, unmaskedContext);
  }

  let nextChildren;
  let hasId;
  prepareToReadContext(workInProgress, renderLanes);
  if (enableSchedulingProfiler) {
    markComponentRenderStarted(workInProgress);
  }
  if (__DEV__) {
    nextChildren = renderWithHooks(
      current,
      workInProgress,
      Component,
      nextProps,
      context,
      renderLanes,
    );
    hasId = checkDidRenderIdHook();

Domain

Subdomains

Frequently Asked Questions

What does updateFunctionComponent() do?
updateFunctionComponent() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberBeginWork.js.
Where is updateFunctionComponent() defined?
updateFunctionComponent() is defined in packages/react-reconciler/src/ReactFiberBeginWork.js at line 1422.
What does updateFunctionComponent() call?
updateFunctionComponent() calls 6 function(s): bailoutOnAlreadyFinishedWork, getIsHydrating, markComponentRenderStarted, markComponentRenderStopped, reconcileChildren, validateFunctionComponentInDev.
What calls updateFunctionComponent()?
updateFunctionComponent() is called by 4 function(s): beginWork, mountIncompleteFunctionComponent, updateHostRoot, updateSimpleMemoComponent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free