React 笔记— Hooks
本文基于官方 v18.1.0 文档。
Introducing Hooks
They let you use state and other React features without writing a class.
It’s hard to reuse stateful logic between components
现在可以通过自定义 Hook 提取封装带状态的逻辑。
Complex components become hard to understand
useEffect
可以把复杂逻辑分拆到多个小的函数中。