如何实现一个 react hook,你有没有自己写过一个
Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 153 (opens in a new tab)
Author 回答者: shfshanyue (opens in a new tab)
可以参考官方文档 https://reactjs.org/docs/hooks-custom.html (opens in a new tab)
自定义一个 hook
仅仅是一个以 use
打头,组合 useState
和 useEffect
或者其它 hooks
的一个普通函数
Author 回答者: into-piece (opens in a new tab)
各种优秀实现=》https://github.com/streamich/react-use (opens in a new tab)
Author 回答者: shfshanyue (opens in a new tab)
各种优秀实现=》https://github.com/streamich/react-use (opens in a new tab)
这个厉害!