diff --git a/src/content/reference/rules/react-calls-components-and-hooks.md b/src/content/reference/rules/react-calls-components-and-hooks.md index b76960b73a..a5472cc5b0 100644 --- a/src/content/reference/rules/react-calls-components-and-hooks.md +++ b/src/content/reference/rules/react-calls-components-and-hooks.md @@ -17,13 +17,13 @@ React 必须决定 [在渲染过程中](/reference/rules/components-and-hooks-mu ```js {2} function BlogPost() { - return
; // ✅ Good: Only use components in JSX + return
; // ✅ 正确的:只在 JSX 中使用组件 } ``` ```js {2} function BlogPost() { - return {Article()}; // 🔴 Bad: Never call them directly + return {Article()}; // 🔴 错误的:不要直接调用组件函数 } ``` @@ -53,7 +53,7 @@ Hook 应当尽可能保持“静态”。这意味着你不应该动态地改变 ```js {2} function ChatInput() { - const useDataWithLogging = withLogging(useData); // 🔴 Bad: don't write higher order Hooks + const useDataWithLogging = withLogging(useData); // 🔴 错误的:不要编写高阶 Hook const data = useDataWithLogging(); } ``` @@ -62,11 +62,11 @@ Hook 应该是不可变的,不应被动态改变。与其动态地改变 Hook ```js {2,6} function ChatInput() { - const data = useDataWithLogging(); // ✅ Good: Create a new version of the Hook + const data = useDataWithLogging(); // ✅ 正确的:创建一个新的 Hook } function useDataWithLogging() { - // ... Create a new version of the Hook and inline the logic here + // ... 创建一个新的 Hook,并将逻辑直接内联到这里 } ``` @@ -76,7 +76,7 @@ Hook 也不应该被动态使用,例如,不应该通过将 Hook 作为值传 ```js {2} function ChatInput() { - return