mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +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
|
||||
const nuxt = useNuxtApp()
|
||||
|
||||
const getCachedData = () => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]
|
||||
const hasCachedData = () => getCachedData() !== undefined
|
||||
// toRef to make sure asyncData and useNuxtData are synced
|
||||
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
|
||||
if (!nuxt._asyncData[key]) {
|
||||
|
Loading…
Reference in New Issue
Block a user