Skip to content

Sync with react.dev @ e9a7cb1b #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
[compiler] Add note about gating evaluation (#7891)
* [compiler] Flesh out incremental adoption intro more

Previously the intro was pretty barebones. Fleshed it out a bit more to describe why it might be useful to reach for in a large codebase.

* [compiler] Add note about gating evaluation

Clarify when the gating function is evaluated.
  • Loading branch information
poteto authored Jul 21, 2025
commit b6450e8f2d89235350932e332195f8549dcf2391
4 changes: 3 additions & 1 deletion src/content/reference/react-compiler/gating.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Configures runtime feature flag gating for compiled functions.
// src/utils/feature-flags.js
export function shouldUseCompiler() {
// your logic here
return Math.random() < 0.5;
return getFeatureFlag('react-compiler-enabled');
}
```

Expand Down Expand Up @@ -94,6 +94,8 @@ const Button = shouldUseCompiler()
: function Button_original(props) { /* original version */ };
```

Note that the gating function is evaluated once at module time, so once the JS bundle has been parsed and evaluated the choice of component stays static for the rest of the browser session.

---

## Troubleshooting {/*troubleshooting*/}
Expand Down