Skip to content

Commit

Permalink
Update src/content/reference/react/useReducer.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucohny authored Jul 12, 2023
1 parent 7f2f555 commit dad4e42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/content/reference/react/useReducer.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function MyComponent() {
#### 注意事项 {/*caveats*/}
* `useReducer` 是一个 Hook,所以你只能在 **组件的顶层作用域** 或者自己的 Hooks 中调用。不能在循环或条件语句中调用。如果你有这种需求,可以创建一个新的组件,并把 state 移入其中。
* `useReducer` 是一个 Hook,所以你只能在 **组件的顶层作用域** 或者自己的 Hook 中调用。不能在循环或条件语句中调用。如果你有这种需求,可以创建一个新的组件,并把 state 移入其中。
* 严格模式下 React 会 **调用两次 reducer 和初始化函数**,这可以 [帮助你发现意外的副作用](#my-reducer-or-initializer-function-runs-twice)。这只是开发模式下的行为,并不会影响生产环境。只要 reducer 和初始化函数是纯函数(理应如此)就不会改变你的逻辑。其中一个调用结果会被忽略。
---
Expand Down

0 comments on commit dad4e42

Please sign in to comment.