Skip to content

Commit ce7b76c

Browse files
authored
docs(plugin-react): translate enableProfiler to Chinese (#2157)
1 parent 8c939b5 commit ce7b76c

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

.changeset/clean-hornets-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rsbuild/babel-preset": patch
3+
---
4+
5+
release: 0.6.5

website/docs/en/plugins/list/plugin-react.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,23 @@ pluginReact({
148148

149149
### enableProfiler
150150

151-
When set to true, enables the React Profiler for performance analysis in production builds. Use the React DevTools to examine profiling results and identify potential performance optimizations. Profiling adds a slight overhead, so it's disabled by default in production environments.
151+
- **Type:** `boolean`
152+
- **Default:** `false`
153+
154+
When set to `true`, enables the React Profiler for performance analysis in production builds. Use the React DevTools to examine profiling results and identify potential performance optimizations. Profiling adds a slight overhead, so it's disabled by default in production environments.
152155

153156
```ts title="rsbuild.config.ts"
154157
pluginReact({
155-
// Only enable the profiler when REACT_PROFILER is true, as the option will increase the build time and adds some small additional overhead.
158+
// Only enable the profiler when REACT_PROFILER is true,
159+
// as the option will increase the build time and adds some small additional overhead.
156160
enableProfiler: process.env.REACT_PROFILER === 'true',
157161
});
158162
```
159163

160-
Set `REACT_PROFILER` when running build script.
164+
Set `REACT_PROFILER=true` when running build script:
161165

162-
```
166+
```bash
163167
REACT_PROFILER=true npx rsbuild build
164168
```
169+
170+
> See the [React docs](https://legacy.reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-devtools-profiler) for details about profiling using the React DevTools.

website/docs/zh/plugins/list/plugin-react.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,26 @@ pluginReact({
147147
},
148148
});
149149
```
150+
151+
### enableProfiler
152+
153+
- **类型:** `boolean`
154+
- **默认值:** `false`
155+
156+
当设置为 `true` 时,在生产构建中启用 React 性能分析器以用于性能分析。需要搭配 React DevTools 来检查分析结果并识别潜在的性能优化方案。分析会增加一些额外开销,因此出于性能考虑,在生产环境中默认是禁用的。
157+
158+
```ts title="rsbuild.config.ts"
159+
pluginReact({
160+
// 仅在 REACT_PROFILER 为 true 时启用性能分析器
161+
// 因为该选项会增加构建时间并产生一些额外开销
162+
enableProfiler: process.env.REACT_PROFILER === 'true',
163+
});
164+
```
165+
166+
执行构建脚本时,设置 `REACT_PROFILER=true` 即可:
167+
168+
```bash
169+
REACT_PROFILER=true npx rsbuild build
170+
```
171+
172+
> 关于使用 React DevTools 进行性能分析的详细信息,请参见 [React 文档](https://legacy.reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-devtools-profiler)

0 commit comments

Comments
 (0)