ahooks 3.11.0
中文
新功能
useClickAway的第三个参数支持配置对象,新增enabled选项,用于控制是否绑定外部点击监听。原有事件名字符串和事件名数组调用方式保持兼容。#2984
修复
useInfiniteScroll避免空页引起连续自动请求,并在加载状态更新完成后再检查是否需要继续加载。7369875、587ea88useInfiniteScroll在容器尺寸或视口变化后重新判断是否需要加载,避免初次尺寸通知触发额外请求。#2964useInfiniteScroll.cancel()清除loadingMore,使取消后的按钮操作和滚动加载能够继续工作,同时忽略已取消请求的结果及回调。#2970useCookieState删除 Cookie 时保留配置的path、domain等属性,修复自定义作用域下无法删除 Cookie 的问题。#2977useTheme在服务端渲染时避免访问浏览器存储。#2983useResetState正确保留函数类型的状态值,初始化和重置时不再把该值作为状态更新函数执行。#2982useDynamicList.sortList保留0、false和空字符串,同时继续过滤null和undefined。#2981useSelections在itemKey属性名或回调变化后重新计算选中映射与选中状态。#2980useExternal和useFavicon正确识别带查询参数或片段的资源 URL 类型,并保留元素上的原始 URL。#2979useHistoryTravel在批量设置值、前进、后退及重置后更新时保留正确的历史记录。#2978useMutationObserver使用最新回调,同时保留原生回调参数和this,回调变化不会重建 observer。#2973
文档
- 说明
useSessionStorageState的listenStorageChange支持同页 Hook 更新及同一标签页内的同源 iframe 更新,不会跨标签页同步。#2972 - 补充维护者发布指南,涵盖 npm、GitHub Release、文档站发布及发布后验收。
使用示例
useClickAway(onClickAway, target, {
eventName: 'click',
enabled: open,
});本次发布包为 ahooks。独立包 @ahooks.js/use-url-state 保持原版本。
English
Features
- Accept an options object as the third argument of
useClickAway, with anenabledoption to control whether outside-click listeners are attached. Existing event-name string and array arguments remain supported. #2984
Fixes
- Prevent repeated automatic requests after an empty page in
useInfiniteScroll, and defer bottom checks until loading state updates complete. 7369875, 587ea88 - Recheck whether more data is needed when the scroll container or viewport changes size, without treating the initial resize notification as a resize. #2964
- Clear
loadingMorewhen cancellinguseInfiniteScrollrequests, allowing subsequent button and scroll loading while continuing to ignore cancelled responses and callbacks. #2970 - Preserve configured Cookie attributes, including
pathanddomain, when removing Cookies throughuseCookieState. #2977 - Avoid accessing browser storage during server rendering in
useTheme. #2983 - Preserve function-valued state in
useResetStateinstead of invoking the value as a state updater during initialization or reset. #2982 - Preserve
0,false, and empty strings inuseDynamicList.sortList, while continuing to filter outnullandundefined. #2981 - Recompute selection maps and flags when the
useSelectionskey property or callback changes. #2980 - Infer resource types correctly for URLs with queries or fragments in
useExternalanduseFavicon, preserving the original element URLs. #2979 - Preserve history during batched updates, navigation, and updates following a reset in
useHistoryTravel. #2978 - Invoke the latest
useMutationObservercallback while preserving its native arguments and receiver, without recreating the observer when the callback changes. #2973
Documentation
- Clarify that
useSessionStorageStatewithlistenStorageChangesynchronizes Hook updates on the same page and storage updates from same-origin iframes in the same tab, but not across tabs. #2972 - Add a maintainer release guide covering npm, GitHub Releases, documentation deployment, and release verification.
Usage example
useClickAway(onClickAway, target, {
eventName: 'click',
enabled: open,
});This release publishes ahooks only. The separate @ahooks.js/use-url-state package keeps its existing version.
Full changelog: v3.10.0...v3.11.0