Skip to content

Commit 0d07e6e

Browse files
authored
Merge pull request #140 from InhiblabCore/dev
fix: use-request auto collect deps first request twice
2 parents 466242d + 1d63c5a commit 0d07e6e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/hooks/src/useRequest/docs/refreshDeps/demo/demo1.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<vhp-button type="button" @click="count++">count is {{ count }}</vhp-button>
55
<div style="opacity: 0.6;"> count !==0 and count !==5 ready is true </div>
66
</div>
7-
<br>
7+
<br />
88
<vhp-button @click="() => (id = 1)">Change ID = 1</vhp-button>
99
<vhp-button @click="() => (id = 2)" style="margin-left: 16px;">Change ID = 2</vhp-button>
1010
<vhp-button @click="() => (store.id = 1)" style="margin-left: 16px;">
@@ -77,7 +77,7 @@
7777
})
7878
const count = ref(0)
7979
80-
const ready = computed(() => count.value !== undefined)
80+
const ready = computed(() => count.value !== 0 && count.value !== 5)
8181
const { data, loading } = useRequest(
8282
() => getUsername({ id: id.value, storeId: store.id, count: count.value }),
8383
{
@@ -89,7 +89,6 @@
8989
},
9090
ready,
9191
refreshDeps: true,
92-
debounceWait: 1000,
9392
},
9493
)
9594
</script>

packages/hooks/src/useRequest/plugins/useAutoRunPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const useAutoRunPlugin: UseRequestPlugin<unknown, unknown[]> = (
99
const hasAutoRun = ref(false)
1010

1111
watchEffect(() => {
12-
if (!manual) hasAutoRun.value = unref(ready)
12+
if (!manual && fetchInstance.options.refreshDeps !== true) hasAutoRun.value = unref(ready)
1313
})
1414

1515
if (refreshDeps instanceof Array)

0 commit comments

Comments
 (0)