File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
src/content/reference/react-compiler Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ title: gating
2121
2222---
2323
24- ## Reference {/* reference* /}
24+ ## 参考 {/* reference* /}
2525
2626### ` gating ` {/* gating* /}
2727
2828为已编译函数配置运行时特性开关的 gating。
2929
30- #### Type {/* type* /}
30+ #### 类型 {/* type* /}
3131
3232```
3333{
@@ -62,7 +62,7 @@ title: gating
6262``` js
6363// src/utils/feature-flags.js
6464export function shouldUseCompiler () {
65- // your logic here
65+ // 此处是你的逻辑
6666 return getFeatureFlag (' react-compiler-enabled' );
6767}
6868```
@@ -90,8 +90,8 @@ function Button(props) {
9090import { shouldUseCompiler } from ' ./src/utils/feature-flags' ;
9191
9292const Button = shouldUseCompiler ()
93- ? function Button_optimized (props ) { /* compiled version */ }
94- : function Button_original (props ) { /* original version */ };
93+ ? function Button_optimized (props ) { /* 编译后的版本 */ }
94+ : function Button_original (props ) { /* 源版本 */ };
9595```
9696
9797注意,gating 函数在模块加载时只会执行一次,因此一旦 JS 包被解析并执行,组件的选择将在本次浏览器会话的剩余时间内保持不变。
Original file line number Diff line number Diff line change @@ -81,12 +81,12 @@ npm install react-compiler-runtime@latest
81812 . 配置 target:
8282
8383``` js
84- // For React 18
84+ // 对于 React 18
8585{
8686 target: ' 18'
8787}
8888
89- // For React 17
89+ // 对于 React 17
9090{
9191 target: ' 17'
9292}
You can’t perform that action at this time.
0 commit comments