github alibaba/hooks v2.0.0

latest releases: v3.7.11, v3.7.10, v3.7.9...
3 years ago

从 umi hooks 升级为 ahooks

升级概览

  • 新增了 3 个 Hooks
  • 删除了 Umi Hooks 中废弃的 6 个 Hooks
  • 制定了 API 规范,对 Hooks 进行了 API 升级
  • 所有的 DOM 类 Hooks 不再返回 ref
  • 部分 Hooks 不兼容升级

升级详情

新增

删除

删除的 6 个 Hooks 可以用 useRequest 代替

  • 删除了 useLoadMore
  • 删除了 useAntdTable
  • 删除了 useAPI
  • 删除了 useAsync
  • 删除了 usePagination
  • 删除了 useSearch

其它

  • useFormTable
    • 重命名为 useAntdTable
  • useRequest
    • 内置请求库从 umi-request 变成了 fetch 
    • 增加了 options.ready 配置,可以方便的实现依赖请求
    • 增加了 options.throwOnError 配置
    • Provider 从 UseAPIProvider 改名为 UseRequestProvider 
  • useDebounce
    • 基于 lodash.debounce 实现,支持更多参数
  • useDebounceFn
    • 基于 lodash.debounce 实现,支持更多参数
    • 删除了 deps 参数
  • useThrottle
    • 基于 lodash.throttle 实现,支持更多参数
  • useThrottleFn
    • 基于 lodash.throttle 实现,支持更多参数
    • 删除了 deps 参数
  • useBoolean
    • API 升级
  • useToggle
    • API 升级
  • useEventTarget
    • API 升级
  • useDocumentVisibility
    • 如果 document 不存在,返回值从 true 变为 undefined
  • useSize
    • API 升级,同时不再返回 ref
  • useScroll
    • API 升级,同时不再返回 ref 
  • useTextSelection
    • API 升级,同时不再返回 ref 
  • useInViewport
    • API 升级,同时不再返回 ref
  • useFullscreen
    • API 升级,同时不再返回 ref 
  • useEventListener
    • API 升级,同时不再返回 ref
  • useClickAway
    • API 升级,同时不再返回 ref 
  • useHover
    • API 升级,同时不再返回 ref 
  • useKeyPress
    • API 升级,同时不再返回 ref 

Upgraded from umi hooks to ahooks

Upgrade overview

  • Added 3 Hooks
  • 6 abandoned Hooks in Umi Hooks were deleted
  • Formulated API specification, upgraded the Hooks API
  • All DOM class Hooks no longer return ref
  • Some Hooks are incompatible with upgrades

Upgrade details

Add

Delete

The deleted 6 Hooks can be replaced by useRequest

  • Deleted useLoadMore
  • Deleted useAntdTable
  • Deleted useAPI
  • Deleted useAsync
  • Deleted usePagination
  • Deleted useSearch

Other

  • useFormTable
    • Rename to useAntdTable
  • useRequest
    • Built-in request Library from umi-request Became fetch
    • Added options.ready Configuration, can easily implement dependency requests
    • Added options.throwOnError Configuration, can easily implement dependency requests
    • Change the Provider name from UseAPIProvider to UseRequestProvider
  • useDebounce
    • Based on lodash.debounce Implementation, support more parameters
  • useDebounceFn
    • Based on lodash.debounce Implementation, support more parameters
    • Deleted deps Parameter
  • useThrottle
    • Based on lodash.throttle Implementation, support more parameters
  • useThrottleFn
    • Based on lodash.throttle Implementation, support more parameters
    • Deleted deps Parameter
  • useBoolean
    • API upgrade
  • useToggle
    • API upgrade
  • useEventTarget
    • API upgrade
  • useDocumentVisibility
    • If the document does not exist, the return value is from true Into undefined
  • useSize
    • API upgrade, and no longer return ref
  • useScroll
    • API upgrade, and no longer return ref
  • useTextSelection
    • API upgrade, and no longer return ref
  • useInViewport
    • API upgrade, and no longer return ref
  • useFullscreen
    • API upgrade, and no longer return ref
  • useEventListener
    • API upgrade, and no longer return ref
  • useClickAway
    • API upgrade, and no longer return ref
  • useHover
    • API upgrade, and no longer return ref 
  • useKeyPress
    • API upgrade, and no longer return ref

Don't miss a new hooks release

NewReleases is sending notifications on new releases.