Skip to content

[Compiler Bug]: Compiler introduces unnecessary breaks that skips its own memoization #34108

@refparo

Description

@refparo

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-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wApg+XJ0wJ8AXwCU+YAB02+OKzAEAtgjUQmALwSF8AXnxQwCdpoj9+MwwD5ZC-M6UqCANzKUo44xjF0YEzuCDYA3E4uTCT4-CJiRobGcuAAFji4APq4CDBqKTLyii74MAi4sGye3ggRxZL4CJRmjvXO1T4AdGpQuGQ54ZElZRUwVV4+dSUSkRIANPgA2vEIALpSU6XllfgAPITBdgASTZQQ+ADqOJQGwBpauvoSuwD0B+52dTN0IBJAA

(Update: made the repro shorter and more generic)

Repro steps

  1. See the playground link.
  2. Look at the two breaks the compiler introduced in the output. The memoization is skipped by the two breaks, making the result of useMemo always new in each render.

How often does this bug happen?

Every time

What version of React are you using?

Both 18.3.1 and the version used by Playground

What version of React Compiler are you using?

Both 19.1.0-rc.2 and the version used by Playground

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions