mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-21 19:31:57 +00:00
[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.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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*/}
|
||||
|
||||
Reference in New Issue
Block a user