From 7a01375f2002ddb3410aae9be60aba465dc31dfd Mon Sep 17 00:00:00 2001 From: wumingdao Date: Mon, 3 Nov 2025 10:55:25 +0800 Subject: [PATCH] docs: Add some translate in /reference/react-compiler --- src/content/reference/react-compiler/gating.md | 10 +++++----- src/content/reference/react-compiler/target.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/reference/react-compiler/gating.md b/src/content/reference/react-compiler/gating.md index b96e21a289..567c90fe0e 100644 --- a/src/content/reference/react-compiler/gating.md +++ b/src/content/reference/react-compiler/gating.md @@ -21,13 +21,13 @@ title: gating --- -## Reference {/*reference*/} +## 参考 {/*reference*/} ### `gating` {/*gating*/} 为已编译函数配置运行时特性开关的 gating。 -#### Type {/*type*/} +#### 类型 {/*type*/} ``` { @@ -62,7 +62,7 @@ title: gating ```js // src/utils/feature-flags.js export function shouldUseCompiler() { - // your logic here + // 此处是你的逻辑 return getFeatureFlag('react-compiler-enabled'); } ``` @@ -90,8 +90,8 @@ function Button(props) { import { shouldUseCompiler } from './src/utils/feature-flags'; const Button = shouldUseCompiler() - ? function Button_optimized(props) { /* compiled version */ } - : function Button_original(props) { /* original version */ }; + ? function Button_optimized(props) { /* 编译后的版本 */ } + : function Button_original(props) { /* 源版本 */ }; ``` 注意,gating 函数在模块加载时只会执行一次,因此一旦 JS 包被解析并执行,组件的选择将在本次浏览器会话的剩余时间内保持不变。 diff --git a/src/content/reference/react-compiler/target.md b/src/content/reference/react-compiler/target.md index ed0a2417dd..5f1413d9a7 100644 --- a/src/content/reference/react-compiler/target.md +++ b/src/content/reference/react-compiler/target.md @@ -81,12 +81,12 @@ npm install react-compiler-runtime@latest 2. 配置 target: ```js -// For React 18 +// 对于 React 18 { target: '18' } -// For React 17 +// 对于 React 17 { target: '17' }