ahooks 阿里家的一批工具 hooks,功能不一定比其他库丰富,但更贴合 Antd 组件库的使用习惯,毕竟是从 Antd 大量业务里提炼出来的。 useRequest:少写请求的 loading、refresh,还有防抖、节流、轮询: const books = useRequest(async () => getBooks(), { refreshDeps: [bookID] }) useAntdTable:封装 Antd Table 的分页/过滤/排序请求,自带搜索、重置。 useToggle:在两个状态值间切换: const [state, { toggle }] = useToggle('dark', 'light') useSetState:合并式的 setState,不用自己展开剩余参数: const [params, setParams] = useSetState({ username: 'abc', email: '' }) setParams({ email: 'hello@me.com' })

ahooks 3.0ahooks.js.org
← 全部动态