I know my use case is probably pretty niche but when dynamically rendering a template for instance on a UCard, the <component :is="as" ...> wrapper introduces a
[Vue warn]: Hydration node mismatch:
- Client vnode: div
- Server rendered DOM: <!--]-->
and delays rendering of the template content.
I am fetching dynamic content from a headless CMS (storyblok) using an useAsyncData or equivalent await useAsyncStoryblok and passing the data down the component chain.
Copying the source of UCard, creating a new component, and replacing the <component ...> with a standard div wrapper
fixes the hydration error.
Or, ssr: false fixes the problem.
Version
@nuxthq/ui: 2.3.0
nuxt: nuxt@3.5.3
Reproduction Link
Proxy Card Component that handles incoming async
/storyblok/Card.vue
1) Fresh nuxt 3 with nuxt UI
2) Add storyblok module
3) Dynamically hydrate named templates from async data.
4) Browser throws an SSR Hydration Error and delays rendering.
What is Expected?
Instant rendering and matching hydration from async data.
What is actually happening?
Delayed rendering and hydration mismatch error on named templates.
Potential Fix?
Maybe include a v-if switch to signal the use of <component :is="as" ...> if the as prop is defined on associated components?
Background
I know my use case is probably pretty niche but when dynamically rendering a template for instance on a UCard, the
<component :is="as" ...>
wrapper introduces aand delays rendering of the template content. I am fetching dynamic content from a headless CMS (storyblok) using an
useAsyncData
or equivalentawait useAsyncStoryblok
and passing the data down the component chain. Copying the source of UCard, creating a new component, and replacing the <component ...> with a standard div wrapper fixes the hydration error. Or,ssr: false
fixes the problem.Version
@nuxthq/ui: 2.3.0 nuxt: nuxt@3.5.3
Reproduction Link
Proxy Card Component that handles incoming async /storyblok/Card.vue
Slug Page that retrieves all found storyblok content /pages/[...slug].vue
Note:
useAsyncStoryblok
as outlined hereA 'fixed' copy of UCard
Steps to reproduce
1) Fresh nuxt 3 with nuxt UI 2) Add storyblok module 3) Dynamically hydrate named templates from async data. 4) Browser throws an SSR Hydration Error and delays rendering.
What is Expected?
Instant rendering and matching hydration from async data.
What is actually happening?
Delayed rendering and hydration mismatch error on named templates.
Potential Fix?
Maybe include a v-if switch to signal the use of
<component :is="as" ...>
if theas
prop is defined on associated components?