react / react/react

[Compiler Bug]: Destructuring props leads to under-optimized component

Open
#36,281 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Unconfirmed 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/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAggBTBEBuAhgDZgA0RAdGwA4wTthEC+ASiLAAOsSJxCYHETREAvETK06UBGCHyAfNXpqwLALY12ZZZp1UiAaiKduBtBAgCA3GKJEYCHLGIAeABM8Ki1gNGV6DT5-AHpg0PdMPjExDGx8QiIAITJ7HiFRcUlMaVkFJRV9C11VdSMTMyoaq1t8x2c3Dy8fPyIgkLCI9pYVaLiErSS+EEYQErQ8AHMUECLPWNjJQ3Y8OhpMzABZCECEZCIREHo6K7EZubAACwgAdwBJTBwEGEwolDQUQQfCAA

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.