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

[Bug]: Hydration attribute mismatch errors after upgrading to Nuxt 3.9.0 and Vue 3.4.0 #577

Closed
lotus-x opened this issue Jan 2, 2024 · 17 comments
Labels
bug Something isn't working

Comments

@lotus-x
Copy link

lotus-x commented Jan 2, 2024

Environment

Developement/Production OS: Arch Linux
Node version: 20.9.0
Package manager: [email protected]
Radix Vue version: 1.2.5
Vue version: 3.4.0
Nuxt version: 3.9.0
Nuxt mode: universal
Nuxt target: server
CSS framework: [email protected]
Client OS: Windows 10 19043.1110
Browser: Chrome 120.0.6099.130

Link to minimal reproduction

https://stackblitz.com/edit/github-shdqqw?file=app.vue

Steps to reproduce

Encountered when using Collapsible, Tabs, Toggles etc.

Should be reproducible on any radix element which uses Primitive under the hood.

Describe the bug

This has already reported in few places,

nuxt/nuxt#24994
nuxt/ui#1171

Maybe the current native useId implementation is messed up after the vue update? (nuxt/nuxt#23368)

Expected behavior

No response

Context & Screenshots (if applicable)

No response

@lotus-x lotus-x added the bug Something isn't working label Jan 2, 2024
@nikuscs
Copy link

nikuscs commented Jan 2, 2024

Please see : #558

@lotus-x
Copy link
Author

lotus-x commented Jan 2, 2024

Please see : #558

Thanks!

@lotus-x lotus-x closed this as completed Jan 2, 2024
@zernonia zernonia pinned this issue Jan 16, 2024
@adirizky54
Copy link

adirizky54 commented Jan 30, 2024

There is new composable in Nuxt about this issue called useId SSR-safe accessible unique ID creation

@zernonia
Copy link
Member

Yup @adirizky54 ! Atinux mentioned that to us but we want to have framework agnositc composable. This way anyone using @vue/server-renderer also benefit from it.

FYI useId composable was planned to release on Vue 3.5 😁

@BayBreezy
Copy link
Contributor

I am getting the hydration mismatch warnings in the console for pretty much all the Radix components that use an id internally.
Sadly, I cant pass in my own id.

You are saying we have to just wait until vue releases their useId composable, correct? @zernonia

@zernonia
Copy link
Member

zernonia commented Mar 6, 2024

Hey guys! With v1.5, we've added a workaround for the hydration issue that happened in Nuxt.

<!-- in Nuxt's app.vue -->
<script setup lang="ts">
import { ConfigProvider } from 'radix-vue'

const useIdFunction = () => useId()
</script>

<template>
  <ConfigProvider :use-id="useIdFunction">
    …
  </ConfigProvider>
</template>

@danielohling
Copy link

danielohling commented Mar 15, 2024

@zernonia

Wonderfull ! 🚀

oliveryh added a commit to oliveryh/clear-habits that referenced this issue Apr 13, 2024
Previously, a hydration mismatch caused by differing IDs within radix-vue
was making the UI unusable. Although hydration mismatches still appear to
occur, the UI appears to be functional with this workaround.

Related to: unovue/radix-vue#577
@sabiqhasby
Copy link

Hey guys! With v1.5, we've added a workaround for the hydration issue that happened in Nuxt.

<!-- in Nuxt's app.vue -->
<script setup lang="ts">
import { ConfigProvider } from 'radix-vue'

const useIdFunction = () => useId()
</script>

<template>
  <ConfigProvider :use-id="useIdFunction">
    …
  </ConfigProvider>
</template>

Thanks, my problems has been solved.

@nidhishs
Copy link

nidhishs commented May 8, 2024

Thanks, my problems has been solved.

@sabiqhasby, by solved, do you mean the warnings no longer show up, or is the UI functional with the warning still visible in the console?

@Ulrich-Mbouna
Copy link

Hey guys! With v1.5, we've added a workaround for the hydration issue that happened in Nuxt.

<!-- in Nuxt's app.vue -->
<script setup lang="ts">
import { ConfigProvider } from 'radix-vue'

const useIdFunction = () => useId()
</script>

<template>
  <ConfigProvider :use-id="useIdFunction">
    …
  </ConfigProvider>
</template>

What if we use another Css Framework for style, for example UIkit and faced hygratation mismatch errors?

@insuber
Copy link

insuber commented Jun 26, 2024

@zernonia It seems that the issue still persists in some components, #919
And I've encountered the same problem while using MenubarTrigger, even after setting up <ConfigProvider :use-id="useIdFunction">

@Ev357
Copy link

Ev357 commented Jun 27, 2024

@zernonia It seems that the issue still persists in some components, #919 And I've encountered the same problem while using MenubarTrigger, even after setting up <ConfigProvider :use-id="useIdFunction">

I also have the same issue with TabsTrigger

@zernonia
Copy link
Member

Thanks @insuber @Ev357 ! I'll investigate shortly and reopen the ticket if needed ya 😁

@Ev357
Copy link

Ev357 commented Jun 30, 2024

Ok, so my dumb mistake, i did not put my app.vue into the new app folder while i was migrating stuff over to Nuxt 4.

@michaelsieminski
Copy link

@zernonia this error still happening with Navigation Menu using NuxtLinks the ConfigProvider useId fix doesnt seem to help

@zernonia
Copy link
Member

zernonia commented Aug 7, 2024

@michaelsieminski can you share a minimal reproduction please? 🙏🏻

@michaelsieminski
Copy link

michaelsieminski commented Aug 7, 2024

@michaelsieminski can you share a minimal reproduction please? 🙏🏻

I have realized the example in the docs was just wrong as it was using 2 a tags, so I made a PR here: unovue/shadcn-vue#702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests