From 85212068ac15d106c13a1973b591403b00a28d7d Mon Sep 17 00:00:00 2001 From: Viki Date: Wed, 9 Oct 2024 20:21:21 +0800 Subject: [PATCH] fix(useQuery): fix `useQuery` `errorRetryCount` default value, set to 0 --- packages/react-use/src/use-query/index.mdx | 4 ++-- packages/react-use/src/use-query/index.ts | 4 ++-- packages/react-use/src/use-query/index.zh-cn.mdx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-use/src/use-query/index.mdx b/packages/react-use/src/use-query/index.mdx index 4370d6b..cb95a51 100644 --- a/packages/react-use/src/use-query/index.mdx +++ b/packages/react-use/src/use-query/index.mdx @@ -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 }) diff --git a/packages/react-use/src/use-query/index.ts b/packages/react-use/src/use-query/index.ts index 6038f9b..6bb913e 100644 --- a/packages/react-use/src/use-query/index.ts +++ b/packages/react-use/src/use-query/index.ts @@ -144,7 +144,7 @@ export interface UseQueryOptions>, /** * Error retry interval * - * @defaultValue 0 + * @defaultValue `defaultRetryInterval` in `useRetryFn` */ errorRetryInterval?: UseRetryFnOptions['interval'] /** @@ -206,7 +206,7 @@ export function useQuery>, E = any> return promise }) as T, { - count: options.errorRetryCount, + count: options.errorRetryCount ?? 0, interval: options.errorRetryInterval, onErrorRetry: options.onErrorRetry, onRetryFailed: options.onErrorRetryFailed, diff --git a/packages/react-use/src/use-query/index.zh-cn.mdx b/packages/react-use/src/use-query/index.zh-cn.mdx index 1bb2333..62feee4 100644 --- a/packages/react-use/src/use-query/index.zh-cn.mdx +++ b/packages/react-use/src/use-query/index.zh-cn.mdx @@ -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), // 错误重试失败时的回调 })