Skip to content

Commit 6137428

Browse files
committed
fix(cache):
Fixes stale data value
1 parent 593c507 commit 6137428

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "http-react",
3-
"version": "3.8.6",
3+
"version": "3.8.7",
44
"description": "React hooks for data fetching",
55
"main": "dist/index.js",
66
"scripts": {

src/hooks/use-fetch.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ export function useFetch<FetchDataType = any, TransformData = any>(
244244

245245
const ageKey = ['max-age', resolvedDataKey].join('-')
246246

247-
const paginationCache = cacheProvider.get(resolvedDataKey)
248-
249-
const normalCache = cacheProvider.get(resolvedKey)
250-
251247
const maxAge = getMiliseconds(maxCacheAge || '0 ms')
252248

253249
// Revalidates if passed maxCacheAge has changed
@@ -425,9 +421,12 @@ export function useFetch<FetchDataType = any, TransformData = any>(
425421

426422
const { data, loading, online, error, completedAttempts } = fetchState
427423

428-
const thisCache = paginationCache ?? normalCache ?? data ?? def ?? null
429-
430-
const rawJSON = serialize(data)
424+
const thisCache =
425+
cacheProvider.get(resolvedDataKey) ??
426+
cacheProvider.get(resolvedKey) ??
427+
data ??
428+
def ??
429+
null
431430

432431
const isLoading = isExpired ? isPending(resolvedKey) || loading : false
433432

0 commit comments

Comments
 (0)