facebook/react · error · Error

559

559

Error message

Expected to find a host node. This is a bug in React.

What it means

In the Fabric host config, getPublicInstanceFromHostFiber asserts that a host-component fiber's stateNode resolves to a public host instance; a null result breaks the renderer's own invariant and surfaces as 'Expected to find a host node. This is a bug in React.' It backs host-instance lookup paths used by findHostInstance-style APIs and tooling.

Source

Thrown at packages/react-native-renderer/src/ReactFiberConfigFabric.js:358

  // React resets all the fields in the fiber when the component is unmounted
  // to prevent memory leaks.
  if (instance == null) {
    return null;
  }

  if (internalInstanceHandle.tag === HostText) {
    const textInstance: TextInstance = instance;
    return getPublicTextInstance(textInstance, internalInstanceHandle);
  }

  const elementInstance: Instance = internalInstanceHandle.stateNode;
  return getPublicInstance(elementInstance);
}

function getPublicInstanceFromHostFiber(fiber: Fiber): PublicInstance {
  const publicInstance = getPublicInstance(fiber.stateNode);
  if (publicInstance === null) {
    throw new Error('Expected to find a host node. This is a bug in React.');
  }
  return publicInstance;
}

export function prepareForCommit(containerInfo: Container): null | Object {
  // Noop
  return null;
}

export function resetAfterCommit(containerInfo: Container): void {
  // Noop
}

export function shouldSetTextContent(type: string, props: Props): boolean {
  // TODO (bvaughn) Revisit this decision.
  // Always returning false simplifies the createInstance() implementation,
  // But creates an additional child Fiber for raw text children.
  // No additional native views are created though.

View on GitHub (pinned to eafeac097b)

Solutions

  1. Align react, react-native, and DevTools to a supported version trio.
  2. Retry the inspection after the tree settles (next frame or after the transition completes).
  3. If it reproduces on matched versions, file an issue with the component stack - the message marks a renderer invariant.
Defensive patterns

Strategy: retry

Try / catch

let data;
try {
  data = getInspectorDataForInstance(fiber);
} catch (e) {
  if (/Expected to find a host node/.test(e.message)) {
    await new Promise(resolve => requestAnimationFrame(resolve)); // let the commit settle
    data = getInspectorDataForInstance(fiber);
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Host-fiber traversal (inspector data collection, findHostInstance, DevTools) hitting a host fiber whose stateNode currently has no public instance - for example a tree inspected mid-commit, right as a screen unmounts, or under version-skewed tooling poking fibers directly.

Common situations: react vs react-native version skew; DevTools inspecting during animations or navigation transitions; experimental RN builds where instance lifecycles changed.

Related errors


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