We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2e0acf9 commit 0ef680cCopy full SHA for 0ef680c
1 file changed
src/hooks/useFetch.ts
@@ -11,11 +11,14 @@ export const useLoading = <T>(
11
loading,
12
async (...arg: any[]) => {
13
setLoading(true)
14
- try {
15
- return await p(...arg)
16
- } finally {
+ const data = await p(...arg)
+ if (!fetch || (data as EmptyResp).code !== 401) {
+ // why?
17
+ // because if setLoading(false) here will rerender before navigate
18
+ // maybe cause some bugs
19
setLoading(false)
20
}
21
+ return data
22
},
23
]
24
@@ -37,11 +40,11 @@ const useListLoading = <T, K>(
37
40
38
41
async (key: K, ...arg: any[]) => {
39
42
setLoading(() => key)
- return await p(key, ...arg)
43
+ const data = await p(key, ...arg)
44
45
setLoading(undefined)
46
47
48
49
50
0 commit comments