Skip to content

[Compiler Bug]: false positive for eslint rule react-hooks/static-componentsΒ #34794

@TkDodo

Description

@TkDodo

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/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBAknBAHYCyCFUBAvgQGYwQYEDkAAgPRrkKYTgG4AOhQmCwhDAEMsWNBQDmBALwEAFAEoNAPiISCBGAjywKpQTTriKDexIQAPHPhZQKcPGkoEAYXYcClo8XSMrAmlCMn9NeUVlFV17ExiCAEEKCDwACwQYOKtNYtsoCWNTc0ttKpMAHgATNAA3fXqTAgbi6IgAG1x1MRAAdzy0PAQRgl4OqK7u7NyCosE+wZhhsYmpmbnOht4W9qqdewYQABoQQWY0FRR0bFxCPABPLAQiAgAFfqgKmUAHksL5KGBGCw2BxOAAjORwhD9AC0WABQIoKLMch8KPI2DQ-UKxzQMlElQoWmAVV4vAJSn6cnB1AgTQQyAIIzk-X6IwkTDAzLJ9wQkP+gJBYL8QnO13AeQgoxIFCmMAoPLAKGYmoQDCAA

Repro steps

The reproduction shows 1 Lint Error:

Error: Cannot create components during render

But the component is stable as the mapping function only returns a reference to a stable component, which should be allowed.

How often does this bug happen?

Every time

What version of React are you using?

19.2.0

What version of React Compiler are you using?

"eslint-plugin-react-hooks": "7.0.0"

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