blog: 更新React hook笔记
This commit is contained in:
parent
7a662a9288
commit
57dccdeb6f
|
|
@ -1,3 +1,13 @@
|
|||
---
|
||||
title: 使用State Hook
|
||||
date: 2021-04-06 19:13:06
|
||||
permalink: /pages/82baa3/
|
||||
categories:
|
||||
- 《React》笔记
|
||||
- Hook
|
||||
tags:
|
||||
-
|
||||
---
|
||||
# 02. 使用State Hook
|
||||
|
||||
```jsx
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
---
|
||||
title: 使用Effect Hook
|
||||
date: 2021-04-06 19:13:06
|
||||
permalink: /pages/72710d/
|
||||
categories:
|
||||
- 《React》笔记
|
||||
- Hook
|
||||
tags:
|
||||
-
|
||||
---
|
||||
# 03. 使用Effect Hook(副作用钩子)
|
||||
|
||||
如果你熟悉 React class 的生命周期函数,你可以把 `useEffect` Hook 看做 `componentDidMount`(挂载完成),`componentDidUpdate`(更新完成) 和 `componentWillUnmount`(即将销毁前) 这三个函数的组合。
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
---
|
||||
title: Hook规则
|
||||
date: 2021-04-06 19:13:06
|
||||
permalink: /pages/723be7/
|
||||
categories:
|
||||
- 《React》笔记
|
||||
- Hook
|
||||
tags:
|
||||
-
|
||||
---
|
||||
# 04. Hook规则
|
||||
|
||||
Hook 本质就是 JavaScript 函数,但是在使用它时需要遵循**两条规则**。我们提供了一个 [linter 插件](https://www.npmjs.com/package/eslint-plugin-react-hooks)来强制执行这些规则:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
---
|
||||
title: 自定义 Hook
|
||||
date: 2021-04-06 19:13:06
|
||||
permalink: /pages/cf1018/
|
||||
categories:
|
||||
- 《React》笔记
|
||||
- Hook
|
||||
tags:
|
||||
-
|
||||
---
|
||||
# 05. 自定义 Hook
|
||||
|
||||
**通过自定义 Hook,可以将组件逻辑提取到可重用的函数中。**
|
||||
|
|
|
|||
Loading…
Reference in New Issue