Skip to content

Commit 4047f4f

Browse files
committed
[compiler] Add note about gating evaluation
Clarify when the gating function is evaluated.
1 parent ab0b9c2 commit 4047f4f

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)