Home / Function/ injectInternals() — react Function Reference

injectInternals() — react Function Reference

Architecture documentation for the injectInternals() function in ReactFiberDevToolsHook.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  03720492_b6bb_21e0_1a9d_d4452d828079["injectInternals()"]
  1f955e30_ff03_d9f9_d498_58b7dc7858dc["ReactFiberDevToolsHook.js"]
  03720492_b6bb_21e0_1a9d_d4452d828079 -->|defined in| 1f955e30_ff03_d9f9_d498_58b7dc7858dc
  style 03720492_b6bb_21e0_1a9d_d4452d828079 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberDevToolsHook.js lines 50–91

export function injectInternals(internals: Object): boolean {
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
    // No DevTools
    return false;
  }
  const hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  if (hook.isDisabled) {
    // This isn't a real property on the hook, but it can be set to opt out
    // of DevTools integration and associated warnings and logs.
    // https://github.com/facebook/react/issues/3877
    return true;
  }
  if (!hook.supportsFiber) {
    if (__DEV__) {
      console.error(
        'The installed version of React DevTools is too old and will not work ' +
          'with the current version of React. Please update React DevTools. ' +
          'https://react.dev/link/react-devtools',
      );
    }
    // DevTools exists, even though it doesn't support Fiber.
    return true;
  }
  try {
    rendererID = hook.inject(internals);

    // We have successfully injected, so now it is safe to set up hooks.
    injectedHook = hook;
  } catch (err) {
    // Catch all errors because it is unsafe to throw during initialization.
    if (__DEV__) {
      console.error('React instrumentation encountered an error: %o.', err);
    }
  }
  if (hook.checkDCE) {
    // This is the real DevTools.
    return true;
  } else {
    // This is likely a hook installed by Fast Refresh runtime.
    return false;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does injectInternals() do?
injectInternals() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberDevToolsHook.js.
Where is injectInternals() defined?
injectInternals() is defined in packages/react-reconciler/src/ReactFiberDevToolsHook.js at line 50.

Analyze Your Own Codebase

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

Try Supermodel Free