fix(nuxt): don't print layout warning if page is not ssr (#19434)

This commit is contained in:
Daniel Roe 2023-03-03 16:47:08 +00:00 committed by GitHub
parent 588c3ff24c
commit a420369c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,7 +142,7 @@ export const setPageLayout = (layout: string) => {
useState('_layout').value = layout
}
const nuxtApp = useNuxtApp()
if (process.dev && nuxtApp.isHydrating && useState('_layout').value !== layout) {
if (process.dev && nuxtApp.isHydrating && nuxtApp.payload.serverRendered && useState('_layout').value !== layout) {
console.warn('[warn] [nuxt] `setPageLayout` should not be called to change the layout during hydration as this will cause hydration errors.')
}
const inMiddleware = isProcessingMiddleware()