Skip to content

Hydration Mismatch when changing state #1867

Discussion options

You must be logged in to vote

This is due to the order of execution of your components: all except Stage.vue are rendering before you change the isLight to true. So they render with the initial value of false and, on server, never render again. That's why Stage.vue is the only copmonent rendering with false initially, because it's the only one being able to see that change. On client, the false value is picked up on hydration, so all components render with false, causing a Hydration mismatch.

To solve this, you need to ensure the isLight setting is set before any component relying on it is rendered.

In general, avoid setting a global settings that are hydrated in arbitrary components' setup() as it will create Hydrati…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1866 on December 12, 2022 10:43.