Skip to content

Commit f5cb6d3

Browse files
authored
Merge pull request #141 from InhiblabCore/dev
fix: use-request auto collect deps first request twice and ignore mount
2 parents 52f7a08 + 0958055 commit f5cb6d3

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</div>
1717
<div style="margin-top: 16px;">Loading:{{ loading ? 'loading' : '' }}</div>
1818

19-
<div style="margin-top: 16px;"
20-
>Data Value:
19+
<div style="margin-top: 16px;">
20+
<span>Data Value:</span>
2121
<div>
2222
<table>
2323
<thead>

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

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

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

1517
if (refreshDeps instanceof Array)

packages/hooks/src/useRequest/useRequestImplement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function useRequestImplement<TData, TParams extends any[]>(
9393

9494
// manual
9595
onMounted(() => {
96-
if (!manual) {
96+
if (!manual && fetchInstance.options.refreshDeps !== true) {
9797
const params = fetchInstance.state.params || options.defaultParams || []
9898
if (unref(ready)) fetchInstance.run(...(params as TParams))
9999
}

0 commit comments

Comments
 (0)