Hydration mismatch at {{ "" }} inside v-for
See original GitHub issueVersion
2.6.14
Reproduction link
Steps to reproduce
- nuxt: v2.15.18
- node: v16.14.0
<span v-for="(obj, index) in objs" :key="obj.id">{{ "" }}<span>Test</span></span>
Important for me was it in this usecase
<span v-for="(obj, index) in objs" :key="obj.id">{{ index > 0 ? ", " : "" }}<wbr v-if="index > 0"><span>{{obj.text}}</span></span>
I don’t know that much about vue without nuxt, so I can’t say how to reproduce sss, just came here by this comment https://github.com/nuxt/nuxt.js/issues/10390#issuecomment-1100752569
I used nuxt dev
with target: 'static'
in nuxt.config.
What is expected?
normal hydration
What is actually happening?
I get a hydration mismatch because nuxt on ssr somehow thinks there is a node with empty content and undefined type and on clientside there correctly no node.
Workaround
use instead:
<span v-for="(obj, index) in objs" :key="obj.id"><span>{{ "" }}</span><span>Test</span></span>
resp.
<span v-for="(obj, index) in objs" :key="obj.id"><span v-if="index > 0">, </span><wbr v-if="index > 0"><span>Test</span></span>
First posted issue here: https://github.com/nuxt/nuxt.js/issues/10390
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
React 18: Non-recoverable hydration mismatch if ... - GitHub
The hydration mismatch happened due to a mismatch of process.env.NODE_ENV between client and server. The current behavior. Whole UI is unmounted ...
Read more >Avoiding hydration mismatch when using React hooks
Avoiding hydration mismatch when using React hooks. One of the most difficult classes of bugs to track down and fix are those which...
Read more >react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >Handling the React server hydration mismatch error
How to resolve the server mismatch error when hydrating a shared React component that can be used in client-side only or server-side rendered ......
Read more >Hydration Mismatch - vite-plugin-ssr
A hydration mismatch is when the content rendered to HTML in Node.js is not the same than the content rendered in the browser....
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 Free
Top 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
<span v-for="(obj, index) in objs" :key="obj.id">{{ index > 0 ", " : "" }}<wbr v-if="index > 0"><span>{{obj.text}}</span></span>
{{ index > 0 ", " : “” }} This sentence is missing a question mark, it should be {{ index > 0 ? ", " : “” }}
Obviously just a typo in my question 😄 I corrected it