Skip to content

Commit

Permalink
fix: resolves useRquest debounce issue (#2606)
Browse files Browse the repository at this point in the history
Co-authored-by: shiruixing <[email protected]>
  • Loading branch information
ruixingshi and shiruixing authored Aug 5, 2024
1 parent 7fad40b commit ac46912
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/hooks/src/useRequest/src/useRequestImplement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function useRequestImplement<TData, TParams extends any[]>(
options: Options<TData, TParams> = {},
plugins: Plugin<TData, TParams>[] = [],
) {
const { manual = false, ...rest } = options;
const { manual = false, ready = true, ...rest } = options;

if (isDev) {
if (options.defaultParams && !Array.isArray(options.defaultParams)) {
Expand All @@ -24,6 +24,7 @@ function useRequestImplement<TData, TParams extends any[]>(

const fetchOptions = {
manual,
ready,
...rest,
};

Expand All @@ -46,7 +47,7 @@ function useRequestImplement<TData, TParams extends any[]>(
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
Expand Down

0 comments on commit ac46912

Please sign in to comment.