Skip to content

Commit d6ecb97

Browse files
docs(cn): translate reference/rules/index.md into Chinese
1 parent 4a875ce commit d6ecb97

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/content/reference/rules/index.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ title: React 规则
2222

2323
---
2424

25-
## 组件和钩子必须是纯净的 {/*components-and-hooks-must-be-pure*/}
25+
## 组件和 Hook 必须是纯净的 {/*components-and-hooks-must-be-pure*/}
2626

27-
[组件和钩子中的纯净性](/reference/rules/components-and-hooks-must-be-pure) 是 React 的一个关键规则,它使你的应用程序变得可预测、易于调试,并允许 React 自动优化你的代码。
27+
[组件和 Hook 中的纯净性](/reference/rules/components-and-hooks-must-be-pure) 是 React 的一个关键规则,它使你的应用程序变得可预测、易于调试,并允许 React 自动优化你的代码。
2828

2929
* [组件必须是幂等的](/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)——React 组件被假定为总是针对它们一样的输入——props, state, 和 context 返回相同的输出。
3030
* [副作用必须在渲染之外运行](/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)——副作用不应该在渲染中运行,因为 React 可能会多次渲染组件以创建最佳的用户体验。
3131
* [属性和状态是不可变的](/reference/rules/components-and-hooks-must-be-pure#props-and-state-are-immutable)——一个组件的属性和状态是针对单次渲染的不可变快照。永远不要直接修改它们。
32-
* [钩子的返回值和参数是不可变的](/reference/rules/components-and-hooks-must-be-pure#return-values-and-arguments-to-hooks-are-immutable)——一旦值被传递给钩子,你不应该修改它们。就像在 JSX 中的属性一样,值在被传递给钩子时变得不可变
32+
* [Hook 的返回值和参数是不可变的](/reference/rules/components-and-hooks-must-be-pure#return-values-and-arguments-to-hooks-are-immutable)——一旦值被传递给 Hook ,你不应该修改它们。就像在 JSX 中的属性一样,值在被传递给 Hook 时变得不可变
3333
* [值在被传递给 JSX 后是不可变的](/reference/rules/components-and-hooks-must-be-pure#values-are-immutable-after-being-passed-to-jsx)——不要在值已经被用于 JSX 后修改它们。在创建 JSX 之前进行修改。
3434

3535
---
3636

37-
## React 调用组件和钩子 {/*react-calls-components-and-hooks*/}
37+
## React 调用组件和 Hook {/*react-calls-components-and-hooks*/}
3838

39-
[React 负责在必要时渲染组件和钩子以优化用户体验](/reference/rules/react-calls-components-and-hooks) 它是声明式的:你在组件逻辑中告诉 React 需要渲染什么,React 会找出最佳方式将其展示给用户。
39+
[React 负责在必要时渲染组件和 Hook 以优化用户体验](/reference/rules/react-calls-components-and-hooks) 它是声明式的:你在组件逻辑中告诉 React 需要渲染什么,React 会找出最佳方式将其展示给用户。
4040

4141
* [永远不要直接调用组件函数](/reference/rules/react-calls-components-and-hooks#never-call-component-functions-directly)——组件应该只在 JSX 中使用。不要将它们作为常规函数调用。
42-
* [永远不要将钩子作为常规值传递](/reference/rules/react-calls-components-and-hooks#never-pass-around-hooks-as-regular-values)——钩子应该只在组件内部调用。不要将其作为常规值传递。
42+
* [永远不要将 Hook 作为常规值传递](/reference/rules/react-calls-components-and-hooks#never-pass-around-hooks-as-regular-values)—— Hook 应该只在组件内部调用。不要将其作为常规值传递。
4343

4444
---
4545

4646
## Hooks 的规则 {/*rules-of-hooks*/}
4747

48-
钩子使用 JavaScript 函数定义,但它们代表一种特殊的可重用 UI 逻辑,并且它们在调用位置上有限制。当你使用钩子时,需要遵循 [Hooks 的规则](/reference/rules/rules-of-hooks)
48+
Hook 使用 JavaScript 函数定义,但它们代表一种特殊的可重用 UI 逻辑,并且它们在调用位置上有限制。当你使用 Hook 时,需要遵循 [Hooks 的规则](/reference/rules/rules-of-hooks)
4949

50-
* [只在顶层调用钩子](/reference/rules/rules-of-hooks#only-call-hooks-at-the-top-level)——不要在循环、条件或嵌套函数中调用钩子。相反,总是在你的 React 函数的顶层使用钩子,并且在任何早期返回之前使用。
51-
* [只在 React 函数中调用钩子](/reference/rules/rules-of-hooks#only-call-hooks-from-react-functions)——不要从常规 JavaScript 函数中调用钩子
50+
* [只在顶层调用 Hook ](/reference/rules/rules-of-hooks#only-call-hooks-at-the-top-level)——不要在循环、条件或嵌套函数中调用 Hook 。相反,总是在你的 React 函数的顶层使用 Hook ,并且在任何早期返回之前使用。
51+
* [只在 React 函数中调用 Hook ](/reference/rules/rules-of-hooks#only-call-hooks-from-react-functions)——不要从常规 JavaScript 函数中调用 Hook
5252

0 commit comments

Comments
 (0)