Home / Function/ injectProxy() — react Function Reference

injectProxy() — react Function Reference

Architecture documentation for the injectProxy() function in proxy.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  06a325b2_15e1_b60b_59d8_0e05e88623f9["injectProxy()"]
  668e31ea_eaa7_3604_a571_2b6a67d82b6c["proxy.js"]
  06a325b2_15e1_b60b_59d8_0e05e88623f9 -->|defined in| 668e31ea_eaa7_3604_a571_2b6a67d82b6c
  c394f590_bdfa_9662_aa2d_496fa7ad61ab["connectPort()"]
  06a325b2_15e1_b60b_59d8_0e05e88623f9 -->|calls| c394f590_bdfa_9662_aa2d_496fa7ad61ab
  92c898a7_74e3_3db1_b358_21e1a9b73efc["sayHelloToBackendManager()"]
  06a325b2_15e1_b60b_59d8_0e05e88623f9 -->|calls| 92c898a7_74e3_3db1_b358_21e1a9b73efc
  style 06a325b2_15e1_b60b_59d8_0e05e88623f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-extensions/src/contentScripts/proxy.js lines 13–33

function injectProxy({target}: {target: any}) {
  // Firefox's behaviour for injecting this content script can be unpredictable
  // While navigating the history, some content scripts might not be re-injected and still be alive
  if (!window.__REACT_DEVTOOLS_PROXY_INJECTED__) {
    window.__REACT_DEVTOOLS_PROXY_INJECTED__ = true;

    connectPort();
    sayHelloToBackendManager();

    // The backend waits to install the global hook until notified by the content script.
    // In the event of a page reload, the content script might be loaded before the backend manager is injected.
    // Because of this we need to poll the backend manager until it has been initialized.
    const intervalID: IntervalID = setInterval(() => {
      if (backendInitialized) {
        clearInterval(intervalID);
      } else {
        sayHelloToBackendManager();
      }
    }, 500);
  }
}

Domain

Subdomains

Frequently Asked Questions

What does injectProxy() do?
injectProxy() is a function in the react codebase, defined in packages/react-devtools-extensions/src/contentScripts/proxy.js.
Where is injectProxy() defined?
injectProxy() is defined in packages/react-devtools-extensions/src/contentScripts/proxy.js at line 13.
What does injectProxy() call?
injectProxy() calls 2 function(s): connectPort, sayHelloToBackendManager.

Analyze Your Own Codebase

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

Try Supermodel Free