File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ button { margin-right: 10px; }
76
76
77
77
组件通常需要根据交互改变屏幕上的内容。在表单中键入更新输入栏,在轮播图上点击“下一个”改变显示的图片,点击“购买”将产品放入购物车。组件需要“记住”一些东西:当前的输入值、当前的图片、购物车。在 React 中,这种特定于组件的记忆被称为状态。
78
78
79
- 你可以用 [ ` useState ` ] ( /reference/usestate ) Hook 为组件添加状态。* Hook* 是能让你的组件使用 React 功能的特殊函数(状态是这些功能之一)。` useState ` Hook 让你声明一个状态变量。它接收初始状态并返回一对值:当前状态,以及一个让你更新状态的设置函数。
79
+ 你可以用 [ ` useState ` ] ( /reference/react/useState ) Hook 为组件添加状态。* Hook* 是能让你的组件使用 React 功能的特殊函数(状态是这些功能之一)。` useState ` Hook 让你声明一个状态变量。它接收初始状态并返回一对值:当前状态,以及一个让你更新状态的设置函数。
80
80
81
81
``` js
82
82
const [index , setIndex ] = useState (0 );
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ translators:
13
13
14
14
<YouWillLearn >
15
15
16
- * 如何使用 [ ` useState ` ] ( /reference/usestate ) Hook 添加 state 变量
16
+ * 如何使用 [ ` useState ` ] ( /reference/react/useState ) Hook 添加 state 变量
17
17
* ` useState ` Hook 返回哪一对值
18
18
* 如何添加多个 state 变量
19
19
* 为什么 state 被称作是局部的
@@ -164,7 +164,7 @@ button {
164
164
1 . ** 保留** 渲染之间的数据。
165
165
2 . ** 触发** React 使用新数据渲染组件(重新渲染)。
166
166
167
- [ ` useState ` ] ( /reference/usestate ) Hook 提供了这两个功能:
167
+ [ ` useState ` ] ( /reference/react/useState ) Hook 提供了这两个功能:
168
168
169
169
1 . ** State 变量** 用于保存渲染间的数据。
170
170
2 . ** State setter 函数** 更新变量并触发 React 再次渲染组件。
@@ -351,7 +351,7 @@ State 只是这些特性中的一个,你之后还会遇到其他 Hook。
351
351
352
352
### 剖析 ` useState ` {/* anatomy-of-usestate* /}
353
353
354
- 当你调用 [ ` useState ` ] ( /reference/usestate ) 时,你是在告诉 React 你想让这个组件记住一些东西:
354
+ 当你调用 [ ` useState ` ] ( /reference/react/useState ) 时,你是在告诉 React 你想让这个组件记住一些东西:
355
355
356
356
``` js
357
357
const [index , setIndex ] = useState (0 );
You can’t perform that action at this time.
0 commit comments