@@ -3,7 +3,7 @@ title: 逐步使用
33---
44
55<Intro >
6- React Compiler 可以逐步采用 ,允许你首先在代码库的特定部分尝试使用。本指南将向你展示如何在现有项目中逐步推广该编译器的使用。
6+ React 编译器可以逐步采用 ,允许你首先在代码库的特定部分尝试使用。本指南将向你展示如何在现有项目中逐步推广该编译器的使用。
77</Intro >
88
99<YouWillLearn >
@@ -19,7 +19,7 @@ React Compiler 可以逐步采用,允许你首先在代码库的特定部分
1919
2020## 为何采用渐进式迁移? {/* why-incremental-adoption* /}
2121
22- React Compiler 的设计目的是自动优化你的整个代码库 ,但你不必一次性全部采用。渐进式采用让你能够控制推行过程,在扩展到其余部分之前,先在应用程序的小部分上测试编译器。
22+ React 编译器的设计目的是自动优化你的整个代码库 ,但你不必一次性全部采用。渐进式采用让你能够控制推行过程,在扩展到其余部分之前,先在应用程序的小部分上测试编译器。
2323
2424从小处着手有助于建立对编译器优化的信心。你可以验证应用在编译代码下的行为是否正确,测量性能提升,并识别代码库中的任何特定边缘情况。这种方法对于稳定性至关重要的生产应用程序尤其有价值。
2525
@@ -70,7 +70,7 @@ module.exports = {
7070// babel.config.js
7171module .exports = {
7272 plugins: [
73- // Global plugins
73+ // 全局插件
7474 ],
7575 overrides: [
7676 {
@@ -82,7 +82,7 @@ module.exports = {
8282 {
8383 test: ' ./src/legacy/**/*.{js,jsx,ts,tsx}' ,
8484 plugins: [
85- // Different plugins for legacy code
85+ // 针对旧代码的不同插件
8686 ]
8787 }
8888 ]
@@ -102,15 +102,15 @@ module.exports = {
102102 test: ' ./src/experimental/**/*.{js,jsx,ts,tsx}' ,
103103 plugins: [
104104 [' babel-plugin-react-compiler' , {
105- // options ...
105+ // 选项 ...
106106 }]
107107 ]
108108 },
109109 {
110110 test: ' ./src/production/**/*.{js,jsx,ts,tsx}' ,
111111 plugins: [
112112 [' babel-plugin-react-compiler' , {
113- // options ...
113+ // 选项 ...
114114 }]
115115 ]
116116 }
@@ -146,7 +146,7 @@ module.exports = {
146146
147147``` js
148148function TodoList ({ todos }) {
149- " use memo" ; // Opt this component into compilation
149+ " use memo" ; // 这个组件在编译里的选项
150150
151151 const sortedTodos = todos .slice ().sort ();
152152
@@ -160,7 +160,7 @@ function TodoList({ todos }) {
160160}
161161
162162function useSortedData (data ) {
163- " use memo" ; // Opt this hook into compilation
163+ " use memo" ; // 这个组件在编译里的选项
164164
165165 return data .slice ().sort ();
166166}
@@ -204,7 +204,7 @@ module.exports = {
204204``` js
205205// ReactCompilerFeatureFlags.js
206206export function isCompilerEnabled () {
207- // Use your feature flag system
207+ // 使用你的特性开关系统
208208 return getFeatureFlag (' react-compiler-enabled' );
209209}
210210```
0 commit comments