Node attribute value is not reactive after client side hydration
See original GitHub issueVersion
2.6.11
Reproduction link
https://codesandbox.io/s/ssr-reactivity-up6nh?file=/pages/index.vue
Steps to reproduce
- The id attribute of the
div
does not match the myid value from the component (requires page refresh sometimes on first load). - Notice that
$forceUpdate()
(first button) does not update the id attribute of thediv
- Changing the value of the
val
data (second button) property triggers the reactivity
What is expected?
Every reference to the myid
computed property should match
What is actually happening?
The id attribute of the div
does not match the myid
value
The same component used in client-side rendering does not exhibit this issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Understand and solve hydration errors in Vue.js - sum.cumo
Hydration refers to the client-side process during which Vue takes over ... Differences in attributes or text nodes do not lead to errors....
Read more >dom-expressions/community - Gitter
The problem with hydration is instead of working on offscreen nodes we are working on live ones. So if the data isn't present...
Read more >Why Efficient Hydration in JavaScript Frameworks is so ...
But it means no client side transitions and loss of client state on navigation. Effectively, Partial Hydration is an improved version of our ......
Read more >Server-Side Rendering (SSR) - Vue.js
To make the client-side app interactive, Vue needs to perform the hydration step. During hydration, it creates the same Vue application that was...
Read more >react-hydration-error - Next.js
In general this issue is caused by using a specific library or application code that is relying on something that could differ between...
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
Hi, I encountered the same issue Is there any other solution than having to use mounted ? We generate unique IDs for our components and use them also for some aria attributes
If we set those ID’s in mounted, we will loose SEO gain from accessibility attributes
Edit: putting a ref on the bugging node solve the issue
@posva yeah it looks similar to #10260, but I’m not knowledgeable enough about Vue internals to be sure.
I did update my repro to use
Vue.prototype.$isServer
instead ofMath.random()
for greater clarity.