From ac46912d00832bb2f6f3bbdcff9ebe4a2e970ee3 Mon Sep 17 00:00:00 2001 From: rising <32844198+ruixingshi@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:20:27 +0800 Subject: [PATCH] fix: resolves useRquest debounce issue (#2606) Co-authored-by: shiruixing --- packages/hooks/src/useRequest/src/useRequestImplement.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/hooks/src/useRequest/src/useRequestImplement.ts b/packages/hooks/src/useRequest/src/useRequestImplement.ts index e8bcfe45ae..d65cfba6cb 100644 --- a/packages/hooks/src/useRequest/src/useRequestImplement.ts +++ b/packages/hooks/src/useRequest/src/useRequestImplement.ts @@ -14,7 +14,7 @@ function useRequestImplement( options: Options = {}, plugins: Plugin[] = [], ) { - const { manual = false, ...rest } = options; + const { manual = false, ready = true, ...rest } = options; if (isDev) { if (options.defaultParams && !Array.isArray(options.defaultParams)) { @@ -24,6 +24,7 @@ function useRequestImplement( const fetchOptions = { manual, + ready, ...rest, }; @@ -46,7 +47,7 @@ function useRequestImplement( fetchInstance.pluginImpls = plugins.map((p) => p(fetchInstance, fetchOptions)); useMount(() => { - if (!manual) { + if (!manual && ready) { // useCachePlugin can set fetchInstance.state.params from cache when init const params = fetchInstance.state.params || options.defaultParams || []; // @ts-ignore