{"record":{"id":"91456520868324c2","repo":"facebook/react","slug":"387","errorCode":"387","errorMessage":"Should have a current fiber. This is a bug in React.","messagePattern":"Should have a current fiber\\. This is a bug in React\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-reconciler/src/ReactFiberBeginWork.js","lineNumber":1839,"sourceCode":"      root.pendingContext,\n      root.pendingContext !== root.context,\n    );\n  } else if (root.context) {\n    // Should always be set\n    pushTopLevelContextObject(workInProgress, root.context, false);\n  }\n  pushHostContainer(workInProgress, root.containerInfo);\n}\n\nfunction updateHostRoot(\n  current: null | Fiber,\n  workInProgress: Fiber,\n  renderLanes: Lanes,\n) {\n  pushHostRootContext(workInProgress);\n\n  if (current === null) {\n    throw new Error('Should have a current fiber. This is a bug in React.');\n  }\n\n  const nextProps = workInProgress.pendingProps;\n  const prevState: RootState = workInProgress.memoizedState;\n  const prevChildren = prevState.element;\n  cloneUpdateQueue(current, workInProgress);\n  processUpdateQueue(workInProgress, nextProps, null, renderLanes);\n\n  const nextState: RootState = workInProgress.memoizedState;\n  const root: FiberRoot = workInProgress.stateNode;\n  pushRootTransition(workInProgress, root, renderLanes);\n\n  if (enableTransitionTracing) {\n    pushRootMarkerInstance(workInProgress);\n  }\n\n  const nextCache: Cache = nextState.cache;\n  pushCacheProvider(workInProgress, nextCache);","sourceCodeStart":1821,"sourceCodeEnd":1857,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-reconciler/src/ReactFiberBeginWork.js#L1821-L1857","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Update react/react-dom - root lifecycle bugs get patched in point releases","Audit unmount-then-render sequences; create a fresh root instead of reusing an unmounted one","Remove or upgrade libraries that mutate React internals (legacy hot loaders, enzyme-era adapters)","Reproduce in isolation and file an issue if it persists on the latest version"],"exampleFix":"// before\nroot.unmount();\nroot.render(<App />); // reuses an unmounted root\n\n// after\nroot.unmount();\nconst root2 = createRoot(container);\nroot2.render(<App />);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Treat root.unmount() as terminal - create a new root to render again","Keep test utilities and hot-reload tooling version-matched to React","Register onUncaughtError on the root so root-level invariants are logged with their component stack"],"tags":["fiber-root","root-lifecycle","invariant","beginwork"],"backgroundTag":"react-internal-invariant","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}