Skip to content

Commit a581c6f

Browse files
authored
fix(useFetchye): forceInitialFetch (#103)
* fix(useFetchye): forceInitialFetch * fix(useFetchye): forceInitialFetch
1 parent 21c00f5 commit a581c6f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/fetchye/src/useFetchye.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ const useFetchye = (
6666
}
6767
const { loading, data, error } = selectorState.current;
6868

69-
if (data && forceInitialFetch.current) {
69+
if (data && forceInitialFetch.current && !loading) {
7070
// This is so it clears the cache before the forceFetch so we don't have isLoading true
7171
// and data also defined from the cached value.
72+
forceInitialFetch.current = false;
7273
dispatch(setAction({ hash: computedKey.hash, value: undefined }));
7374
runAsync({
7475
dispatch, computedKey, fetcher: selectedFetcher, fetchClient, options,
7576
});
76-
forceInitialFetch.current = false;
7777
return;
7878
}
7979

8080
if (!loading && !data && !error) {
81+
forceInitialFetch.current = false;
8182
runAsync({
8283
dispatch, computedKey, fetcher: selectedFetcher, fetchClient, options,
8384
});
84-
forceInitialFetch.current = false;
8585
}
8686
});
8787
return {

0 commit comments

Comments
 (0)