mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +00:00
fix(nuxt3): set pending to false when using cached data (#4067)
This commit is contained in:
parent
f39fd9f0a0
commit
c426f3e5e0
@ -81,9 +81,11 @@ export function useAsyncData<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const useInitialCache = () => options.initialCache && nuxt.payload.data[key] !== undefined
|
||||||
|
|
||||||
const asyncData = {
|
const asyncData = {
|
||||||
data: ref(nuxt.payload.data[key] ?? options.default()),
|
data: ref(nuxt.payload.data[key] ?? options.default()),
|
||||||
pending: ref(true),
|
pending: ref(!useInitialCache()),
|
||||||
error: ref(nuxt.payload._errors[key] ?? null)
|
error: ref(nuxt.payload._errors[key] ?? null)
|
||||||
} as AsyncData<DataT>
|
} as AsyncData<DataT>
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ export function useAsyncData<
|
|||||||
return nuxt._asyncDataPromises[key]
|
return nuxt._asyncDataPromises[key]
|
||||||
}
|
}
|
||||||
// Avoid fetching same key that is already fetched
|
// Avoid fetching same key that is already fetched
|
||||||
if (opts._initial && options.initialCache && nuxt.payload.data[key] !== undefined) {
|
if (opts._initial && useInitialCache()) {
|
||||||
return nuxt.payload.data[key]
|
return nuxt.payload.data[key]
|
||||||
}
|
}
|
||||||
asyncData.pending.value = true
|
asyncData.pending.value = true
|
||||||
|
Loading…
Reference in New Issue
Block a user