Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Beta]: docs(cn): state-a-components-memory #651

Merged
merged 11 commits into from
Feb 28, 2023
Prev Previous commit
Next Next commit
Merge branch 'main' into state-a-components-memory
zzwgh committed Feb 20, 2023
commit 030b77f8dbb8b7594e6278668a59f4138fec2d6f
8 changes: 5 additions & 3 deletions beta/src/content/learn/state-a-components-memory.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "State:组件的记忆"
translators:
- 7ooz
- zzw
---

<Intro>
@@ -1328,7 +1328,7 @@ h1 { margin-top: 10px; }

<Hint>

Hooks 只允许在*什么地方* 调用?这个组件是否违反了任何规则?
Hooks 只允许在*什么地方* 调用?这个组件是否违反了任何规则?检查是否有注释禁用了 linter 检查--这往往是 bug 的藏身之处!

</Hint>

@@ -1367,7 +1367,9 @@ export default function FeedbackForm() {

<Solution>

Hooks 只能在组件函数的顶层调用。这里,第一个 `isSent` 定义遵循这个规则,但是 `message` 的定义位于一个条件语句中。将其移出条件语句以解决问题:
Hooks 只能在组件函数的顶层调用。这里,第一个 `isSent` 定义遵循这个规则,但是 `message` 的定义位于一个条件语句中。

将其移出条件语句以解决问题:

<Sandpack>

You are viewing a condensed version of this merge commit. You can view the full changes here.