facebook/react · error · Error

387

387

Error message

Should have a current fiber. This is a bug in React.

What it means

updateHostRoot() processes the HostRoot fiber - the fiber that owns the FiberRoot returned by createRoot()/hydrateRoot(). A HostRoot update always implies the root previously mounted, so its current (alternate) fiber must exist. A null current here means the fiber tree around the root is in an impossible state.

Source

Thrown at packages/react-reconciler/src/ReactFiberBeginWork.js:1839

      root.pendingContext,
      root.pendingContext !== root.context,
    );
  } else if (root.context) {
    // Should always be set
    pushTopLevelContextObject(workInProgress, root.context, false);
  }
  pushHostContainer(workInProgress, root.containerInfo);
}

function updateHostRoot(
  current: null | Fiber,
  workInProgress: Fiber,
  renderLanes: Lanes,
) {
  pushHostRootContext(workInProgress);

  if (current === null) {
    throw new Error('Should have a current fiber. This is a bug in React.');
  }

  const nextProps = workInProgress.pendingProps;
  const prevState: RootState = workInProgress.memoizedState;
  const prevChildren = prevState.element;
  cloneUpdateQueue(current, workInProgress);
  processUpdateQueue(workInProgress, nextProps, null, renderLanes);

  const nextState: RootState = workInProgress.memoizedState;
  const root: FiberRoot = workInProgress.stateNode;
  pushRootTransition(workInProgress, root, renderLanes);

  if (enableTransitionTracing) {
    pushRootMarkerInstance(workInProgress);
  }

  const nextCache: Cache = nextState.cache;
  pushCacheProvider(workInProgress, nextCache);

View on GitHub (pinned to eafeac097b)

Solutions

  1. Update react/react-dom - root lifecycle bugs get patched in point releases
  2. Audit unmount-then-render sequences; create a fresh root instead of reusing an unmounted one
  3. Remove or upgrade libraries that mutate React internals (legacy hot loaders, enzyme-era adapters)
  4. Reproduce in isolation and file an issue if it persists on the latest version

Example fix

// before
root.unmount();
root.render(<App />); // reuses an unmounted root

// after
root.unmount();
const root2 = createRoot(container);
root2.render(<App />);
Defensive patterns

Strategy: try-catch

Try / catch

Render-phase invariant at the root: an ErrorBoundary catches it, but a corrupted root fiber means the safest recovery is unmounting and re-creating the root with createRoot.

Prevention

When it happens

Trigger: beginWork reaches the HostRoot update path with no current fiber - reported with React internal bugs around root re-creation, unmount-then-render races, and custom renderers that reuse FiberRoots. No public API is designed to produce it.

Common situations: Calling root.unmount() and then root.render() on the same root; a concurrent render racing a root unmount; older hot-reload or test utilities that reach into react-dom internals pinned against a newer React.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/91456520868324c2. Report an issue: GitHub.