Home / Function/ useHook() — react Function Reference

useHook() — react Function Reference

Architecture documentation for the useHook() function in todo.memoize-loops-that-produce-memoizeable-values.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  f9bddff2_3f08_c6b3_cf08_8301bed29655["useHook()"]
  ae20494b_aa5a_9b44_9234_dcea356b0e2e["todo.memoize-loops-that-produce-memoizeable-values.js"]
  f9bddff2_3f08_c6b3_cf08_8301bed29655 -->|defined in| ae20494b_aa5a_9b44_9234_dcea356b0e2e
  style f9bddff2_3f08_c6b3_cf08_8301bed29655 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo.memoize-loops-that-produce-memoizeable-values.js lines 1–16

function useHook(nodeID, condition) {
  const graph = useContext(GraphContext);
  const node = nodeID != null ? graph[nodeID] : null;

  // (2) Instead we can create a scope around the loop since the loop produces an escaping value
  let value;
  for (const key of Object.keys(node?.fields ?? {})) {
    if (condition) {
      // (1) We currently create a scope just for this instruction, then later prune the scope because
      // it's inside a loop
      value = new Class(node.fields?.[field]);
      break;
    }
  }
  return value;
}

Domain

Subdomains

Frequently Asked Questions

What does useHook() do?
useHook() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo.memoize-loops-that-produce-memoizeable-values.js.
Where is useHook() defined?
useHook() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo.memoize-loops-that-produce-memoizeable-values.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free