facebook/react · error · Error

isChildPublicInstance() is not available in production.

Error message

isChildPublicInstance() is not available in production.

What it means

ReactNativePublicCompat.isChildPublicInstance is a legacy public-instance ancestry check (used by DevTools/test utilities) whose backing internals are stripped from production bundles; calling it there throws. Like the inspector helpers, it is dev-tooling surface and must not ship in release code paths.

Source

Thrown at packages/react-native-renderer/src/ReactNativePublicCompat.js:214

      // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
      getInternalInstanceHandleFromPublicInstance(parentInstance);
    const childInternalInstanceHandle =
      // $FlowExpectedError[incompatible-call] Type for childInstance should have been PublicInstance from ReactFiberConfigFabric.
      getInternalInstanceHandleFromPublicInstance(childInstance);

    if (
      parentInternalInstanceHandle != null &&
      childInternalInstanceHandle != null
    ) {
      return doesFiberContain(
        parentInternalInstanceHandle,
        childInternalInstanceHandle,
      );
    }

    return false;
  } else {
    throw new Error('isChildPublicInstance() is not available in production.');
  }
}

View on GitHub (pinned to eafeac097b)

Solutions

  1. Guard calls with if (__DEV__).
  2. Keep such utilities in dev/test-only entry points so they are eliminated from release bundles.
  3. For production ancestry needs, keep your own parent/child bookkeeping instead of renderer internals.

Example fix

// before
const contains = isChildPublicInstance(parent, child);

// after
let contains = false;
if (__DEV__) {
  contains = isChildPublicInstance(parent, child);
}
Defensive patterns

Strategy: validation

Validate before calling

let contains = false;
if (__DEV__) {
  contains = isChildPublicInstance(parent, child);
} else {
  // not available in production bundles
}

Type guard

const canUsePublicCompat = () => Boolean(__DEV__);

Prevention

When it happens

Trigger: Calling isChildPublicInstance(parent, child) in a production bundle - typically from test utilities, DevTools glue, or compatibility shims that were accidentally imported into app code.

Common situations: Test helpers imported into app bundles; libraries integrating with RN renderer internals; leftover debugging code from a DevTools integration.

Related errors


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