Home / Function/ unwindWork() — react Function Reference

unwindWork() — react Function Reference

Architecture documentation for the unwindWork() function in ReactFiberUnwindWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ff527c73_3068_e15f_a742_b0c855fedff9["unwindWork()"]
  53e7e9e3_9e8c_648e_1f4e_0fdfa5c5cb8f["ReactFiberUnwindWork.js"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|defined in| 53e7e9e3_9e8c_648e_1f4e_0fdfa5c5cb8f
  696b3a85_2c29_d1fc_9da0_cb0ebaa5bcff["popCacheProvider()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 696b3a85_2c29_d1fc_9da0_cb0ebaa5bcff
  2343b46f_12ff_c0a8_2d57_670c055844f4["popRootMarkerInstance()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 2343b46f_12ff_c0a8_2d57_670c055844f4
  3a69c559_be56_4689_1458_b935319852cb["popHostContainer()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 3a69c559_be56_4689_1458_b935319852cb
  d1a95e98_467c_e9b8_af34_7d3813a82b6b["popHostContext()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| d1a95e98_467c_e9b8_af34_7d3813a82b6b
  59929453_9f09_a335_22ac_e0e931c51842["popSuspenseHandler()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 59929453_9f09_a335_22ac_e0e931c51842
  87c1044e_4880_6c4c_bb78_f18f233bb260["resetHydrationState()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 87c1044e_4880_6c4c_bb78_f18f233bb260
  3be97342_d10e_c947_1b45_9c2bb900f73a["popSuspenseListContext()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 3be97342_d10e_c947_1b45_9c2bb900f73a
  ac44a064_efde_6180_750f_70488159ba8a["popHiddenContext()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| ac44a064_efde_6180_750f_70488159ba8a
  7e859251_7f78_1520_7488_1ea657edb327["popMarkerInstance()"]
  ff527c73_3068_e15f_a742_b0c855fedff9 -->|calls| 7e859251_7f78_1520_7488_1ea657edb327
  style ff527c73_3068_e15f_a742_b0c855fedff9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberUnwindWork.js lines 66–249

function unwindWork(
  current: Fiber | null,
  workInProgress: Fiber,
  renderLanes: Lanes,
): Fiber | null {
  // Note: This intentionally doesn't check if we're hydrating because comparing
  // to the current tree provider fiber is just as fast and less error-prone.
  // Ideally we would have a special version of the work loop only
  // for hydration.
  popTreeContext(workInProgress);
  switch (workInProgress.tag) {
    case ClassComponent: {
      const Component = workInProgress.type;
      if (isLegacyContextProvider(Component)) {
        popLegacyContext(workInProgress);
      }
      const flags = workInProgress.flags;
      if (flags & ShouldCapture) {
        workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
        if (
          enableProfilerTimer &&
          (workInProgress.mode & ProfileMode) !== NoMode
        ) {
          transferActualDuration(workInProgress);
        }
        return workInProgress;
      }
      return null;
    }
    case HostRoot: {
      const root: FiberRoot = workInProgress.stateNode;
      const cache: Cache = workInProgress.memoizedState.cache;
      popCacheProvider(workInProgress, cache);

      if (enableTransitionTracing) {
        popRootMarkerInstance(workInProgress);
      }

      popRootTransition(workInProgress, root, renderLanes);
      popHostContainer(workInProgress);
      popTopLevelLegacyContextObject(workInProgress);
      const flags = workInProgress.flags;
      if (
        (flags & ShouldCapture) !== NoFlags &&
        (flags & DidCapture) === NoFlags
      ) {
        // There was an error during render that wasn't captured by a suspense
        // boundary. Do a second pass on the root to unmount the children.
        workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
        return workInProgress;
      }
      // We unwound to the root without completing it. Exit.
      return null;
    }
    case HostHoistable:
    case HostSingleton:
    case HostComponent: {
      // TODO: popHydrationState
      popHostContext(workInProgress);
      return null;
    }
    case ActivityComponent: {
      const activityState: null | ActivityState = workInProgress.memoizedState;
      if (activityState !== null) {
        popSuspenseHandler(workInProgress);

        if (workInProgress.alternate === null) {
          throw new Error(
            'Threw in newly mounted dehydrated component. This is likely a bug in ' +
              'React. Please file an issue.',
          );
        }

        resetHydrationState();
      }

      const flags = workInProgress.flags;
      if (flags & ShouldCapture) {
        workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
        // Captured a suspense effect. Re-render the boundary.
        if (

Domain

Subdomains

Frequently Asked Questions

What does unwindWork() do?
unwindWork() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberUnwindWork.js.
Where is unwindWork() defined?
unwindWork() is defined in packages/react-reconciler/src/ReactFiberUnwindWork.js at line 66.
What does unwindWork() call?
unwindWork() calls 9 function(s): popCacheProvider, popHiddenContext, popHostContainer, popHostContext, popMarkerInstance, popRootMarkerInstance, popSuspenseHandler, popSuspenseListContext, and 1 more.

Analyze Your Own Codebase

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

Try Supermodel Free