Skip to content

[Compiler] Reading external mutable state #34519

@mecirt

Description

@mecirt

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/#N4Igzg9grgTgxgUxALhHANgQzGABAFQTABddgAdAO11zgkpJijmIhgAoBKM3YgCwCWYAHQB9AG6Z0UIrgC8ZAL4BuXIqo0A5gmLsBAE24VqNXOh24YshfyFjJ0ogG0DAXWUbTAgGa52AQiswbiD5HgByYgQAD2Jw5Fxw8LUPExorYlhqINSadRMwHT19ABpeGOIjTxpzUgQw4ESo2Pjy2JTq3kERCSkZMBd9VzCEXLUqFSoqSRhykjDKBAB3AiJdTlSqGIAHNlJvKEoWAXpVkgBhCABbXcXKXUbFKpNyEChC3EoIXCuEK4hXmM6AxSE4oNt9JgomVvGxEABVCFQhDDBTvBAAZWIyPYxCYCA2nlquAMYQAjGNiQAjMJREjCbS6AyEkzEhDoMLsAA8hFiADEBOz9LgANYIACecnC3kF6H0ySwVPZUsIJAElE0uBlQuSDhkcmAVOEzWIilw9HOfEwGoQBvYBPkAD4eHTiMJCkzSrgEMbMDBGcI9QTVLD4AhEZCogFwZHg2ozQB6R0s9I6LJ+Ln6ATiR3AdmKLkJrM5lmTShTRbRXYwUj6BDeTBQdD7Q7HU4AWXFAEFttsuGRPBl0zy1pcbvQEPdcEnUvkQCU0PQZZoUCABOOa7xxdt6o0AArSTTqgDy22IJwYai1MGuiSpmCV6AAtNtD+qn1ZMCwn3QbgJzDARZCHEmyUOwxg0AmCa-ts-5Qhe7YQHWCSvFI6CvBMuBgPBYDange5+ueUhcgeUBHpQp7nvQYDJso87gHwEBLAAkvcCAwJQUhgCgDboIUihAA

Repro steps

See the playground above - if you remove "use no memo", the generated code caches away the calls to test.get(1) as it incorrectly thinks that it always returns the same thing, and as a result, the TextField doesn't get updated properly.

How often does this bug happen?

Every time

What version of React are you using?

19.1.1

What version of React Compiler are you using?

19.1.0-rc.3

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