react / react/react

[Compiler Bug]: React compiler discards computed property keys when used in method shorthand

Open
#35,203 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Component: React Compiler Type: Bug
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

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://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABOgWwAcpsEATABRgiIGkEBPXAXlwB0QAzCCAIwCGMTgG52GLlAxxsAS0y4AYrwAUASlzBxuHbhgJssDLgA85WQDcAfNt12TAISG5+AKxbBguANqESZKhp6JgBddU1cAF8o6IB6G2NdE1jza3FIkAAaNEwuWQBzFBBZYggYPGxGIgQIygAbKHzZDAB5IjlMMCjcLhoCXAByQT4EOoBaIgamjDH9ARkxv1k6hBgU2RwBsQxxFS1E2NiluoEOjABZCHIEZA4QATq6znTcMFONvIQu+sbmtrOwGoRFlwAALCAAdwAkhgyDAMA8wCguIiEJEgA

Repro steps

See the playground link for the full example.

pass an object with a computed key to a react component
eg:

<Bar obj={{ [computedPropKey]() { } }} />

observe the compiler generates incorrect code

<Bar obj={{ computedPropKey() {} }} />
How often does this bug happen?

Every time

What version of React are you using?

latest on the compiler playground

What version of React Compiler are you using?

latest on the compiler playground

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked React Compiler playground repro and compare the input object with the generated output. No repository file or test is named in the issue; done means a computed property key used with method shorthand remains computed in the compiler output, with coverage for the reported example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.