perf(nuxt): use faster approach to check cache exists (#26172)

This commit is contained in:
Alex Liu 2024-03-11 04:07:00 +08:00 committed by GitHub
parent 6723123a2e
commit ac54da242f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -243,7 +243,7 @@ export function useAsyncData<
console.warn('[nuxt] `boolean` values are deprecated for the `dedupe` option of `useAsyncData` and will be removed in the future. Use \'cancel\' or \'defer\' instead.') console.warn('[nuxt] `boolean` values are deprecated for the `dedupe` option of `useAsyncData` and will be removed in the future. Use \'cancel\' or \'defer\' instead.')
} }
const hasCachedData = () => ![null, undefined].includes(options.getCachedData!(key) as any) const hasCachedData = () => options.getCachedData!(key) != null
// Create or use a shared asyncData entity // Create or use a shared asyncData entity
if (!nuxtApp._asyncData[key] || !options.immediate) { if (!nuxtApp._asyncData[key] || !options.immediate) {