[Compiler Bug]: Destructuring props leads to under-optimized component
Nobody has claimed this yet.
- 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
Repro steps
When we destructure a component's props into another object, the compiled component is less optimal than it could be. In the playground for component A, we only need props.foo in the function, but the compiled component checks for props changing. If we don't use the destructed props (see B) then the compiled result checks for props.foo changing, which is more optimal.
Destructuring props into an object in a component is a fairly common pattern, so this has the potential to significantly reduce the efficiency of React Compiler optimizations.
How often does this bug happen?
Every time
What version of React are you using?
18.2.0
What version of React Compiler are you using?
0.0.0-experimental-a1856f3-20260409
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked React Compiler playground repro and compare the compiled output for components A and B. Trace why destructuring causes the generated component to check the whole props object instead of only props.foo; done means the destructured case produces the same more targeted optimization while preserving behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100