Home / Function/ FunctionWithHooks() — react Function Reference

FunctionWithHooks() — react Function Reference

Architecture documentation for the FunctionWithHooks() function in CustomHooks.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  596e48d9_b3cb_8b34_039c_1cf2ad113432["FunctionWithHooks()"]
  558d1213_8e28_1b9e_f470_2ddacc7d9271["CustomHooks.js"]
  596e48d9_b3cb_8b34_039c_1cf2ad113432 -->|defined in| 558d1213_8e28_1b9e_f470_2ddacc7d9271
  7c8e716d_bb32_934f_c7b2_5bd12bb091c6["useCustomObject()"]
  596e48d9_b3cb_8b34_039c_1cf2ad113432 -->|calls| 7c8e716d_bb32_934f_c7b2_5bd12bb091c6
  dd35387f_c0c2_6df3_16fa_807e917ad5c3["useNestedOuterHook()"]
  596e48d9_b3cb_8b34_039c_1cf2ad113432 -->|calls| dd35387f_c0c2_6df3_16fa_807e917ad5c3
  c2cff9b1_2427_802f_f22c_05535b9ff502["useDeepHookA()"]
  596e48d9_b3cb_8b34_039c_1cf2ad113432 -->|calls| c2cff9b1_2427_802f_f22c_05535b9ff502
  style 596e48d9_b3cb_8b34_039c_1cf2ad113432 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js lines 75–107

function FunctionWithHooks(props: any, ref: React$RefSetter<any>) {
  const [count, updateCount] = useState(0);
  // eslint-disable-next-line no-unused-vars
  const contextValueA = useContext(ContextA);
  useOptimistic<number, mixed>(1);
  use(ContextA);

  // eslint-disable-next-line no-unused-vars
  const [_, __] = useState(object);

  // Custom hook with a custom debug label
  const debouncedCount = useDebounce(count, 1000);

  useCustomObject();

  const onClick = useCallback(
    function onClick() {
      updateCount(count + 1);
    },
    [count],
  );

  // Tests nested custom hooks
  useNestedOuterHook();

  // eslint-disable-next-line no-unused-vars
  const contextValueB = useContext(ContextB);

  // Verify deep nesting doesn't break
  useDeepHookA();

  return <button onClick={onClick}>Count: {debouncedCount}</button>;
}

Domain

Subdomains

Frequently Asked Questions

What does FunctionWithHooks() do?
FunctionWithHooks() is a function in the react codebase, defined in packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js.
Where is FunctionWithHooks() defined?
FunctionWithHooks() is defined in packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js at line 75.
What does FunctionWithHooks() call?
FunctionWithHooks() calls 3 function(s): useCustomObject, useDeepHookA, useNestedOuterHook.

Analyze Your Own Codebase

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

Try Supermodel Free