Skip to content

[Compiler Bug]: Does not check for ref access in useState initial value function #31418

Closed

Description

@aeharding

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/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAKgmDgBQCURwAOsUXIRUTgIYBGASgmkQC8RKGAR80NRkRFiAypxwJKNIQD523CQDo4sGAkw5qAbkYBfEOaA

Repro steps

The playground compiles, but it should fail (Rules of React)

How often does this bug happen?

Every time

What version of React are you using?

latest playground

What version of React Compiler are you using?

latest playground

Activity

  1. added
    Status: Unconfirmed
    on Nov 5, 2024
  2. removed
    Status: Unconfirmed
    on Nov 5, 2024
  3. josephsavona commented on Jul 28, 2025

    @josephsavona
    Contributor

    Thanks for posting! Fix is up at #34025

  4. changed the title [-][Compiler Bug]: Does not check for ref access in setState initial value function[/-] [+][Compiler Bug]: Does not check for ref access in useState initial value function[/+] on Jul 28, 2025
  5. josephsavona commented on Jul 29, 2025

    @josephsavona
    Contributor

    Fix landed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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