Skip to content

[Compiler Bug]: Render counters unregister after the first update #38261

Open

Description

@chengchuu

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-hooks (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://github.com/chengchuu/reproductions/tree/main/react/compiler-render-counters

Repro steps

react-compiler-runtime loses a component's render counter registration after its first update. This example calls useRenderCounter directly and displays the registered counter count after each update.

import { useEffect, useRef, useState } from 'react';
import { renderCounterRegistry, useRenderCounter } from 'react-compiler-runtime';

export function App() {
  const [updates, setUpdates] = useState(0);
  const log = useRef(null);
  useRenderCounter('App');

  useEffect(() => {
    // Observe after the counter's effect without triggering another render.
    const registered = renderCounterRegistry.get('App')?.size ?? 0;
    log.current.textContent += `Updates: ${updates}; registered counters: ${registered}\n`;
  }, [updates]);

  return (
    <main>
      <h1>React Compiler render counter registration</h1>
      <p>Expected: one registered counter while this component is mounted.</p>
      <button onClick={() => setUpdates(updates + 1)}>Update component: {updates}</button>
      <pre ref={log} aria-live="polite" />
    </main>
  );
}

Steps To Reproduce

  1. Follow the reproduction setup instructions to start the app.
  2. Open the URL printed in the terminal and click Update component: 0.

The current behavior

The registered counter count drops from 1 to 0 while the component remains mounted:

Updates: 0; registered counters: 1
Updates: 1; registered counters: 0

Reproduced in Chrome on macOS.

The expected behavior

Updates: 0; registered counters: 1
Updates: 1; registered counters: 1

How often does this bug happen?

Every time

What version of React are you using?

19.3.1

What version of React Compiler are you using?

df6aa4e

Activity

  1. added
    Status: Unconfirmed
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedType: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions