File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
src/content/reference/rules Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -3,18 +3,18 @@ title: Hooks 规则
3
3
---
4
4
5
5
<Intro >
6
- Hooks 是通过 JavaScript 函数定义的, 但它们代表了一种特殊的可重用 UI 逻辑,并且对它们的调用位置有限制 。
6
+ Hooks 是通过 JavaScript 函数定义的, 代表了一种特殊的可重用的 UI 逻辑,它们的调用位置有一定的限制 。
7
7
</Intro >
8
8
9
9
<InlineToc />
10
10
11
11
---
12
12
13
- ## 只在顶层调用 Hooks {/* only-call-hooks-at-the-top-level* /}
13
+ ## 只能在顶层调用 Hooks {/* only-call-hooks-at-the-top-level* /}
14
14
15
- 名称以 ` use ` 开头的函数在 React 中被称为 [ * Hooks* ] ( /reference/react ) 。
15
+ 名称以 ` use ` 开头的函数在 React 中被称为 [ * Hooks* ] ( /reference/react ) 。
16
16
17
- ** 不要在循环、条件、嵌套函数或 ` try ` /` catch ` /` finally ` 块中调用 Hooks ** 相反,你应该在 React 函数的顶层使用 Hooks ,并且在任何提前返回之前。你只能在 React 函数组件中调用 Hooks :
17
+ ** 不要在循环、条件、嵌套函数或 ` try ` /` catch ` /` finally ` 块中调用 Hooks ** 相反,你应该在 React 函数的顶层使用 Hooks ,并且在任何提前返回之前。且你只能在 React 函数组件中调用 Hooks :
18
18
19
19
* ✅ 在[ 函数组件] ( /learn/your-first-component ) 的顶层调用它们。
20
20
* ✅ 在[ 自定义 Hooks ] ( /learn/reusing-logic-with-custom-hooks ) 的顶层调用它们。
@@ -109,7 +109,7 @@ function Bad() {
109
109
110
110
<Note >
111
111
112
- [ 自定义 Hooks] ( /learn/reusing-logic-with-custom-hooks ) * 可以* 调用其他 Hooks (这就是它们的目的)。因为自定义 Hooks 也只应该在函数组件渲染时被调用 。
112
+ [ 自定义 Hooks] ( /learn/reusing-logic-with-custom-hooks ) * 可以* 调用其他 Hooks (这就是它们的目的)。因为自定义 Hooks 也只能在函数组件渲染时被调用 。
113
113
114
114
</Note >
115
115
You can’t perform that action at this time.
0 commit comments