New Hooks progress and ideas
- Hooks development progress tracking
- If you have new Hooks ideas you can follow up
- 新增 Hooks 开发进度追踪
- 如果你有新的 Hooks 想法可以追评
| Name | RFC | Developer | Stage | Remark |
|---|---|---|---|---|
| useTimeout | #527 | @awmleer | ✅ | - |
| useInterval | #437 | @awmleer | ✅ | - |
| useCookie | #455 | @Straw94 | ✅ | - |
| useNetwork | #512 | @brickspert | ✅ | - |
| useTitle | - | @chenbin92 | ✅ | - |
| useUrlState | - | @tty006 | ✅ | - |
| useSetState | #463 | @brickspert | ✅ | - |
| useWhyDidYouUpdate | #471 | @zhaofinger | ✅ | - |
| useWebSocket | - | - | ✅ | - |
| useAnimation | - | - | - | Like use-web-animations, useAnimation |
useEasyReducer #502
useCountDown #576
useFavicon #581
useImperativeInterval #583
useVerifyCode #584
useReactive & useMethods #615
useClipboard #715
useExternal #758
useUnmountedRef #760
~~useFixPage #774~~ Close
useMeta #781
useJsonView #785
useMergeState #794
useRequest、useAntdTable等hooks 提供拦截器
useEventListener #966
useOrder #990
建议可以参考下 react-use,把里面没有的都实现了,个人更喜欢用 ahooks 但是有的功能没有,react-use 更新太慢了,也没人回答问题
useGetState: 在普通 useState 返回值中增加 getter 方法穿透闭包获取最新值 #1306
Getter setter should be added for useState. For example, where I use the state variable, if its value is empty, it should send a request to the api. However, this may cause it to send the same request more than once in duplicate components.
For example, when we normally assign a value to a state variable by request, we use the following structure.
const [state, setState] = useState();
const { run } = useRequest(getStateValue);
useEffect(() => {
run();
}, [])
In some cases we use the same state variable in other pages, it's pointless to repeat this code for each page. For example, when using the ant design useModel hook, if the data is empty, I have to put this code at the beginning of the pages I need. Instead of doing all this, when I just call the state variable, the code should do it without background conflict, it should not send it again if a request has been sent before, it should call it from there if the state value is filled.
useReqState