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: client:load causes hydration sync errors for vue component when using a store #2658

Closed
songololo opened this issue Feb 25, 2022 · 7 comments

Comments

@songololo
Copy link

songololo commented Feb 25, 2022

What version of astro are you using?

0.23.0

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

I have a vue component which works as expected when used without a client: directive, e.g.

<TestC />

But when adding the directive, i.e.

<TestC client:load/>

Then it will load OK on the first load, but afterwards starts returning one of the following two types of errors:

[Vue warn]: Hydration children mismatch in <div>: server rendered element contains more child nodes than client vdom. 
  at <NavTree currentPath="/" > 
  at <App>
Hydration completed but contains mismatches.

or

Uncaught (in promise) Error: Unable to find the root for the component TestC

The issue seems to arise because I'm using a nanostore to share information about my blog posts between different components, which means that the server-side state and client-side state can diverge.

Please see the reproducible repo link.

Thanks!

Link to Minimal Reproducible Example

https://github.com/songololo/astro-debug

@songololo songololo changed the title 🐛 BUG: client:load causes hydration sync errors for vue component when using a store and prop 🐛 BUG: client:load causes hydration sync errors for vue component when using a store Feb 25, 2022
@Bryanoxx
Copy link

Bryanoxx commented Feb 25, 2022

Hello ! Just for reporting: I have the same error/behavior using the v0.23.1 and with client:visible

@kavaro
Copy link

kavaro commented Mar 24, 2022

FYI: Same issue with svelte component that uses a svelte store.

@hayley
Copy link
Contributor

hayley commented Mar 29, 2022

Also having this issue:

  • upgrade from Astro 0.20.12 to 0.25.4
  • svelte component
  • uses svelte stores
  • edit: also happening with nanostores
  • client:visible

Error: Unable to find the root for the component Radar

Edit:
Though nanostores was previously mentioned as a problem, out of curiosity, I wanted to try it in my own setup since the example nanostores project was using client hydration without a problem.

I can confirm though that in my project, both the version using Svelte stores and the version rewritten to use Nanostores will fail with the same component error listed above.

@hayley
Copy link
Contributor

hayley commented Apr 3, 2022

Astro 0.26 update: For the same project of mine previously mentioned, upgrading to Astro 0.26 has not fixed the issue.

I'm still seeing Error: Unable to find the root for the component Radar in the browser console.

@hayley
Copy link
Contributor

hayley commented Apr 4, 2022

Astro 0.26.1 fixes this for me both in the Svelte store and nanostores version.

Based on the changelog (https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md), I'm guessing it was #2978 that fixed this.

To anyone affected by this, I'd encourage you to try 0.26.1 / 1.0 beta.0 to see if it fixes it for you.

@kavaro
Copy link

kavaro commented Apr 4, 2022

I can confirm that Astro 0.26.1 fixes my issues with svelte
Thanks guys

@FredKSchott
Copy link
Member

Sounds like this was fixed in Astro v0.26.1, thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants