diff --git a/packages/hooks/src/useRequest/src/plugins/useCachePlugin.ts b/packages/hooks/src/useRequest/src/plugins/useCachePlugin.ts index b1b004d847..64380e7b68 100644 --- a/packages/hooks/src/useRequest/src/plugins/useCachePlugin.ts +++ b/packages/hooks/src/useRequest/src/plugins/useCachePlugin.ts @@ -47,6 +47,9 @@ const useCachePlugin: Plugin = ( 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