Skip to content

Commit

Permalink
fix: useRequest staleTime=-1 default loading=false
Browse files Browse the repository at this point in the history
  • Loading branch information
brickspert committed Dec 21, 2021
1 parent 5b5e3b6 commit 0a8b87c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/hooks/src/useRequest/src/plugins/useCachePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const useCachePlugin: Plugin<any, any[]> = (
if (cacheData && Object.hasOwnProperty.call(cacheData, 'data')) {
fetchInstance.state.data = cacheData.data;
fetchInstance.state.params = cacheData.params;
if (staleTime === -1 || new Date().getTime() - cacheData.time <= staleTime) {
fetchInstance.state.loading = false;
}
}

// subscribe same cachekey update, trigger update
Expand Down

0 comments on commit 0a8b87c

Please sign in to comment.