mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 21:58:19 +00:00
fix(nuxt): don't set asyncData to existing payload on CSR if initialCache
is disabled (#6640)
This commit is contained in:
parent
006f66900e
commit
33e7fc1752
@ -15,7 +15,7 @@ export type PickFrom<T, K extends Array<string>> = T extends Array<any>
|
||||
export type KeysOf<T> = Array<keyof T extends string ? keyof T : string>
|
||||
export type KeyOfRes<Transform extends _Transform> = KeysOf<ReturnType<Transform>>
|
||||
|
||||
type MultiWatchSources = (WatchSource<unknown> | object)[];
|
||||
type MultiWatchSources = (WatchSource<unknown> | object)[]
|
||||
|
||||
export interface AsyncDataOptions<
|
||||
DataT,
|
||||
@ -112,10 +112,10 @@ export function useAsyncData<
|
||||
}
|
||||
}
|
||||
|
||||
const useInitialCache = () => options.initialCache && nuxt.payload.data[key] !== undefined
|
||||
const useInitialCache = () => (nuxt.isHydrating || options.initialCache) && nuxt.payload.data[key] !== undefined
|
||||
|
||||
const asyncData = {
|
||||
data: ref(nuxt.payload.data[key] ?? options.default?.() ?? null),
|
||||
data: ref(useInitialCache() ? nuxt.payload.data[key] : options.default?.() ?? null),
|
||||
pending: ref(!useInitialCache()),
|
||||
error: ref(nuxt.payload._errors[key] ?? null)
|
||||
} as AsyncData<DataT, DataE>
|
||||
|
Loading…
Reference in New Issue
Block a user