Home / Function/ injectInternals() — react Function Reference

injectInternals() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  c9e2f7f9_7341_411e_6151_de1416af9035["injectInternals()"]
  2795c922_bc1c_8105_46d7_d6274d4e24a9["ReactFlightClientDevToolsHook.js"]
  c9e2f7f9_7341_411e_6151_de1416af9035 -->|defined in| 2795c922_bc1c_8105_46d7_d6274d4e24a9
  style c9e2f7f9_7341_411e_6151_de1416af9035 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-client/src/ReactFlightClientDevToolsHook.js lines 12–43

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.supportsFlight) {
    // DevTools exists, even though it doesn't support Flight.
    return true;
  }
  try {
    hook.inject(internals);
  } 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-client/src/ReactFlightClientDevToolsHook.js.
Where is injectInternals() defined?
injectInternals() is defined in packages/react-client/src/ReactFlightClientDevToolsHook.js at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free