Skip to content

SSR Usage - useHydrateAtoms hook causes a UI missmatch #1982

Closed Answered by fabio-nettis
fabio-nettis asked this question in Q&A
Discussion options

You must be logged in to vote

@wootra I have discovered that the useHydrateAtoms hook was not the issue per-se, but if understood correctly it was a client component accessing the state in a different part of the UI imported dynamically via next/dynamic with the ssr option set to false. This caused the value displayed by the component to change on first render, what in return caused a UI mismatch.

How to I fixed the error

Simply move the component that calls useHydrateAtoms to the top of the component tree, this will ensure that all children will render with the correct value.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@dai-shi
Comment options

@fabio-nettis
Comment options

@wootra
Comment options

wootra Jul 1, 2023
Collaborator

@fabio-nettis
Comment options

Answer selected by fabio-nettis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants