Skip to content

Commit

Permalink
fix(useQuery): fix useQuery errorRetryCount default value, set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Oct 9, 2024
1 parent 669a6c4 commit 8521206
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/react-use/src/use-query/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ console.log(isActive())

### Error Retry \{#error-retry}

Setting `errorRetryCount` and `errorRetryInterval` to numbers greater than 0 will automatically retry the request in case of failure, supported by [useRetryFn](/reference/use-retry-fn).
Setting `errorRetryCount` to numbers greater than 0 will automatically retry the request in case of failure, supported by [useRetryFn](/reference/use-retry-fn).

```ts
const { loading, data, error } = useQuery(fetchData, {
errorRetryCount: 3, // Number of retries in case of error, default 0, off
errorRetryInterval: 1_000, // Interval between retries, default 0, immediate retry
errorRetryInterval: 1_000, // Error retry interval, default use 'useRetryFn' 'defaultRetryInterval', retreat algorithm
onErrorRetry: (error) => console.log(error), // Callback during error retry
onErrorRetryFailed: (error) => console.log(error), // Callback when error retry fails
})
Expand Down
4 changes: 2 additions & 2 deletions packages/react-use/src/use-query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export interface UseQueryOptions<T extends AnyFunc, D = Awaited<ReturnType<T>>,
/**
* Error retry interval
*
* @defaultValue 0
* @defaultValue `defaultRetryInterval` in `useRetryFn`
*/
errorRetryInterval?: UseRetryFnOptions<E>['interval']
/**
Expand Down Expand Up @@ -206,7 +206,7 @@ export function useQuery<T extends AnyFunc, D = Awaited<ReturnType<T>>, E = any>
return promise
}) as T,
{
count: options.errorRetryCount,
count: options.errorRetryCount ?? 0,
interval: options.errorRetryInterval,
onErrorRetry: options.onErrorRetry,
onRetryFailed: options.onErrorRetryFailed,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-use/src/use-query/index.zh-cn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ console.log(isActive())

### 错误重试 \{#error-retry}

设置 `errorRetryCount` `errorRetryInterval` 为大于 0 的数字,将在请求失败时自动重试,由 [useRetryFn](/reference/use-retry-fn) 提供支持。
设置 `errorRetryCount` 为大于 0 的数字,将在请求失败时自动重试,由 [useRetryFn](/reference/use-retry-fn) 提供支持。

```ts
const { loading, data, error } = useQuery(fetchData, {
errorRetryCount: 3, // 错误重试次数,默认 0,关闭
errorRetryInterval: 1_000, // 错误重试间隔,默认 0,立即重试
errorRetryInterval: 1_000, // 错误重试间隔,默认使用 `useRetryFn` 的 `defaultRetryInterval`,退避算法
onErrorRetry: (error) => console.log(error), // 错误重试时的回调
onErrorRetryFailed: (error) => console.log(error), // 错误重试失败时的回调
})
Expand Down

0 comments on commit 8521206

Please sign in to comment.