Hydration node mismatch when overwriting prose components
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.10
- Nitro Version:
0.5.3
- Package Manager:
npm@7.17.0
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/nuxt-starter-dmjv7l?file=components/content/ProseImg.vue
Describe the bug
Updated: my previous report was incorrect and I have isolated the issue to my prose component overwriting. See edit history for my old report if you need.
It looks like the hydration node mismatch happens if I overwrite the img prose component (I haven’t tested other type yet). See the linked reproduction above.
It looks like if I add any extra element to the new ProseImg
component, it will result as a hydration node mismatch error:
[Vue warn]: Hydration children mismatch in <div>: server rendered element contains more child nodes than client vdom.
at <ContentRendererMarkdown value= {_path: '/', _draft: false, _partial: false, _locale: 'en', _empty: false, …} excerpt=false tag="div" >
at <ContentRenderer key="content:index.md" value= {_path: '/', _draft: false, _partial: false, _locale: 'en', _empty: false, …} >
at <Anonymous >
at <Anonymous >
at <Anonymous name="default" >
at <DocumentDriven onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <Anonymous key="/" routeProps= {Component: {…}, route: {…}} pageKey="/" ... >
at <BaseTransition mode="out-in" appear=false persisted=false ... >
at <Transition name="page" mode="out-in" >
at <RouterView name=undefined route=undefined >
at <NuxtPage>
at <App key=1 >
at <NuxtRoot>
To be more specific, having the <div>
tag will trigger this error:
// ProseImg.vue
<template>
<div>
<img :src="src" :alt="alt" :width="width" :height="height" />
</div>
</template>
Maybe the SSR code didn’t see the overwritten component?
Thank you.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Hydration mismatch error due to plugins generating script ...
If a script tag is inserted before the head tag due to the user's browser environment such as a plugin, it is judged...
Read more >Debugging and fixing hydration issues - somewhat abstract
Spotting hydration errors and fixing them can prevent serious user-facing performance issues, and since we do not get a signal during production ...
Read more >node.js - Hydration error in next.js - unmatched text, ...
I have tried modifying getStaticPaths and getStaticProps but this issue still persists.
Read more >Should I ignore these kind of warnings? "Hydration node ...
I am using this package "FormKit" for handling forms and validation. it shows this warning for every element I use and I can't...
Read more >Understand and solve hydration errors in Vue.js
If a component is initially mounted or hydrated in the DOM, it needs to precisely correspond to the HTML generated on the server...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@michaelvcolianna My current work around is to add
<client-only>
tag at the root of my customizedProseImg
component, but it will also disable SSR for images though.@fanzeyi I’m not a fan of this but it works:
/components/content/ProseP.vue