Skip to content

Commit b6450e8

Browse files
authored
[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.
1 parent b462664 commit b6450e8

File tree

1 file changed

+3
-1
lines changed
  • src/content/reference/react-compiler

1 file changed

+3
-1
lines changed

src/content/reference/react-compiler/gating.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Configures runtime feature flag gating for compiled functions.
6363
// src/utils/feature-flags.js
6464
export function shouldUseCompiler() {
6565
// your logic here
66-
return Math.random() < 0.5;
66+
return getFeatureFlag('react-compiler-enabled');
6767
}
6868
```
6969

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

97+
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.
98+
9799
---
98100

99101
## Troubleshooting {/*troubleshooting*/}

0 commit comments

Comments
 (0)