mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +00:00
fix(nuxt): sync useNuxtData and useAsyncData
This commit is contained in:
parent
429d3656e9
commit
6664dcccb9
@ -120,8 +120,9 @@ export function useAsyncData<
|
|||||||
// Setup nuxt instance payload
|
// Setup nuxt instance payload
|
||||||
const nuxt = useNuxtApp()
|
const nuxt = useNuxtApp()
|
||||||
|
|
||||||
const getCachedData = () => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]
|
// toRef to make sure asyncData and useNuxtData are synced
|
||||||
const hasCachedData = () => getCachedData() !== undefined
|
const getCachedData = () => nuxt.isHydrating ? toRef(nuxt.payload.data, key) : nuxt.static.data[key]
|
||||||
|
const hasCachedData = () => unref(getCachedData()) !== undefined
|
||||||
|
|
||||||
// Create or use a shared asyncData entity
|
// Create or use a shared asyncData entity
|
||||||
if (!nuxt._asyncData[key]) {
|
if (!nuxt._asyncData[key]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user