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

Hydration errors when using cart.get() from context #2560

Open
vemundeldegard opened this issue Sep 23, 2024 · 2 comments
Open

Hydration errors when using cart.get() from context #2560

vemundeldegard opened this issue Sep 23, 2024 · 2 comments
Labels
Bug Something isn't working SEV-4

Comments

@vemundeldegard
Copy link

What is the location of your example repository?

Use Skeleton-template

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

2024.7.7

What version of Remix are you using?

2.10.1

Steps to Reproduce

Use Skeleton-template or check any of the latest preview of Skeleton store. E.g. this preview from #2538

Hydration error occurs when adding an item to cart and refreshing the page.
Image

Expected Behavior

There should not be any hydration errors and since the cart is server rendered, it should not fallback to 0 when the cart is not empty on the server.

Actual Behavior

Hydration errors occur when the cart is not empty. If cart is not empty it still shows as 0 before showing the cart total quantity count.

@wizardlyhel
Copy link
Contributor

wizardlyhel commented Sep 23, 2024

Thanks for reporting this issue.

The cart isn't always server rendered. It's in a deferred query so it wouldn't be server rendered unless the cart query returns before the server starts returning the response.

However, the hydration error is something we can look into with maybe using startTransition wrapper for initial state and transition state when the deferred data arrives

@vemundeldegard
Copy link
Author

Aha, thanks for clarifying!

It would be awesome to get rid of the error to avoid confusion. I thought it was something on my end that I did wrong, until I checked for the same error on the Skeleton.

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

No branches or pull requests

2 participants