Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nuxt 3.9] - Hydration STYLE mismatch #25045

Closed
mkierdev opened this issue Jan 4, 2024 · 7 comments
Closed

[Nuxt 3.9] - Hydration STYLE mismatch #25045

mkierdev opened this issue Jan 4, 2024 · 7 comments

Comments

@mkierdev
Copy link

mkierdev commented Jan 4, 2024

Environment

Nuxt 3.9

Reproduction

I tried to upgrade from 3.8.2 to 3.9 using nuxi upgrade

Describe the bug

I've run into issue that was not present in 3.8.2:

Hydration style mismatch on < div class...>​…​​ // etc, replaced upon pasting

  • rendered on server: style="font-size:16px;--spacing:12px;"
  • expected on client: style="font-size: 16px; --spacing: 12px"

What's even more weird is that these properties actually comes from simple props with default values:
(Component simplified for showcase)

withDefaults(defineProps<Props>(), {
  width: 16,
  spacing: 12,
});
<div :style="`font-size: ${width}px; --spacing: ${spacing}px`" />

In another component, if style is generated by computed(), it also returns hydration style mismatch.

Additional context

No response

Logs

No response

@manniL
Copy link
Member

manniL commented Jan 4, 2024

Be aware that Vue 3.9 added more fine-grained hydration info. That issue could've been there for long but was simply undetected. For more insights you have to provide a reproduction ;)

Copy link
Contributor

github-actions bot commented Jan 4, 2024

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@josuelrocha
Copy link

It really seems to be a bug in Nuxt 3.9, in the example below, when you have :style and also v-show to modify the style, the Hydration warning is displayed.

Example to reproduce

Anywhere in a Nuxt 3.9 project, place this code

<div v-show="false" :style="{ width: 'auto' }">test</div>

Console warn

[Vue warn]: Hydration style mismatch on 
<div style="width:auto;display:none;"> 
  - rendered on server: style="width:auto;display:none;"
  - expected on client: style="width:auto;"

@mkierdev
Copy link
Author

mkierdev commented Jan 4, 2024

Moreover, if you are returning default 'server' styles and modify it on the client during first load (ex. When accessing client window and calculating some stuff based on it) you also have this warning. Does not seems good.

@manniL
Copy link
Member

manniL commented Jan 4, 2024

Can you try reproducing this in https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main?terminal=dev ? Might be an upstream issue.

@josuelrocha
Copy link

Really, the problem seems to be coming from Vue and not Nuxt.

https://stackblitz.com/edit/github-dyqiua?file=src%2Fpages%2FHome.vue

vue-warn

@manniL manniL added the upstream label Jan 5, 2024
@manniL
Copy link
Member

manniL commented Jan 5, 2024

Let's track in vuejs/core#10006

@manniL manniL closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants