Home / Function/ useRenderCounter() — react Function Reference

useRenderCounter() — react Function Reference

Architecture documentation for the useRenderCounter() function in index.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ca8d2fc5_a6ca_2a2f_e4e3_d695ef641cae["useRenderCounter()"]
  e7e94027_87c5_661b_dd97_be583c709eb3["index.ts"]
  ca8d2fc5_a6ca_2a2f_e4e3_d695ef641cae -->|defined in| e7e94027_87c5_661b_dd97_be583c709eb3
  82d7425b_049d_aab9_9b5d_9c9e4140aade["registerRenderCounter()"]
  ca8d2fc5_a6ca_2a2f_e4e3_d695ef641cae -->|calls| 82d7425b_049d_aab9_9b5d_9c9e4140aade
  402e9f34_9d6b_60ee_fc3a_3f7a9f3426cc["removeRenderCounter()"]
  ca8d2fc5_a6ca_2a2f_e4e3_d695ef641cae -->|calls| 402e9f34_9d6b_60ee_fc3a_3f7a9f3426cc
  style ca8d2fc5_a6ca_2a2f_e4e3_d695ef641cae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/react-compiler-runtime/src/index.ts lines 228–248

export function useRenderCounter(name: string): void {
  const val = useRef<{count: number}>(null);

  if (val.current != null) {
    val.current.count += 1;
  }
  useEffect(() => {
    // Not counting initial render shouldn't be a problem
    if (val.current == null) {
      const counter = {count: 0};
      registerRenderCounter(name, counter);
      // @ts-ignore
      val.current = counter;
    }
    return () => {
      if (val.current !== null) {
        removeRenderCounter(name, val.current);
      }
    };
  });
}

Domain

Subdomains

Frequently Asked Questions

What does useRenderCounter() do?
useRenderCounter() is a function in the react codebase, defined in compiler/packages/react-compiler-runtime/src/index.ts.
Where is useRenderCounter() defined?
useRenderCounter() is defined in compiler/packages/react-compiler-runtime/src/index.ts at line 228.
What does useRenderCounter() call?
useRenderCounter() calls 2 function(s): registerRenderCounter, removeRenderCounter.

Analyze Your Own Codebase

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

Try Supermodel Free