Skip to content

v1.4.0

Choose a tag to compare

@github-actions github-actions released this 09 Aug 02:20
· 412 commits to main since this release

Add useRequest Hook

useRequest is a common hook for data fetching, supports cache, automatic refresh, and many awesome features.

  • Support basic async operations state management (loading, data, error, params, etc.)
  • Support many lifecycle hooks, such as onBefore, onSuccess, onError, etc.
  • Support continuous automatic refresh, manual refresh, and refresh control
  • Support automatic refresh when the network is reconnected, the page is focused, etc.
  • Support cross-platform visibility and online judgment to control automatic refresh
  • Support error retry, error retry interval, and error retry count
  • Support throttle and debounce for manual refresh
  • Support custom loading timeout, loading slow detection, and loading slow timeout
  • Support cache, cache expiration time, and cache provider (SWR)
  • Support clear cache, get cache, and mutate cache globally or locally
  • Support pausable to control internal automatic behavior
  • Support manual refresh, automatic refresh, and manual control refresh

   🚀 Features

  • New Hook useInputComposition to track composition state of input element  -  by @vikiboss (5be4b)
  • New Hook useLoadingSlowFn to track loading slow state  -  by @vikiboss (732fa)
  • New Hook useReConnect to run a callback when re-connect  -  by @vikiboss (772ab)
  • New Hook useReFocus to run a callback when re-focus  -  by @vikiboss (88cc9)
  • New Hook useRetryFn to create a function with retry mechanism  -  by @vikiboss (2eceb)
  • createSingleLoading:
    • Deprecated, it will be removed in the future, maybe moved to @shined/reactive  -  by @vikiboss (8b479)
  • useAsyncFn:
  • useReactive:
    • Deprecated, it will be removed in the future, maybe moved to @shined/reactive  -  by @vikiboss (03ac5)

   🐞 Bug Fixes

   🏎 Performance

  • useLoadingSlowFn: Using getter to refine performance  -  by @vikiboss (31a59)
    View changes on GitHub

添加 useRequest 钩子

useRequest 是一个常用的数据获取钩子,支持缓存、自动刷新以及许多其他优秀特性。

  • 支持基本异步操作状态管理(加载中、数据、错误、参数等)
  • 支持多种生命周期钩子,例如 onBefore、onSuccess、onError 等
  • 支持连续自动刷新、手动刷新和刷新控制
  • 支持网络重新连接、页面聚焦等时自动刷新
  • 支持跨平台可见性和在线判断来控制自动刷新
  • 支持错误重试、错误重试间隔和错误重试次数
  • 支持对手动刷新进行节流和防抖处理
  • 支持自定义加载超时、加载缓慢检测和加载缓慢超时
  • 支持缓存、缓存过期时间和缓存提供者(SWR)
  • 支持全局或局部地清除缓存、获取缓存和变更缓存
  • 支持暂停以控制内部自动行为
  • 支持手动刷新、自动刷新和手动控制刷新

   🚀 功能

  • 新钩子 useInputComposition 用于追踪 input 元素的组合状态  -  由 @vikiboss 提供 (5be4b)
  • 新钩子 useLoadingSlowFn 用于追踪加载缓慢状态  -  由 @vikiboss 提供 (732fa)
  • 新钩子 useReConnect 用于重新连接时运行回调函数  -  由 @vikiboss 提供 (772ab)
  • 新钩子 useReFocus 用于重新聚焦时运行回调函数  -  由 @vikiboss 提供 (88cc9)
  • 新钩子 useRetryFn 用于创建具有重试机制的函数  -  由 @vikiboss 提供 (2eceb)
  • createSingleLoading:
    • 不推荐使用,将来会被移除,可能移至 @shined/reactive  -  由 @vikiboss 提供 (8b479)
  • useAsyncFn:
  • useReactive:
    • 不推荐使用,将来会被移除,可能移至 @shined/reactive  -  由 @vikiboss 提供 (03ac5)

   🐞 修复

   🏎 性能优化

  • useLoadingSlowFn: 使用 getter 来细化性能  -  由 @vikiboss 提供 (31a59)
    在 GitHub 上查看更改