Skip to content

fix(ui): resolve hydration mismatch in Header and useTheme#272

Open
blazeapps007 wants to merge 1 commit intosteemit:nextfrom
blazeapps007:next
Open

fix(ui): resolve hydration mismatch in Header and useTheme#272
blazeapps007 wants to merge 1 commit intosteemit:nextfrom
blazeapps007:next

Conversation

@blazeapps007
Copy link
Copy Markdown
Contributor

Replace useSyncExternalStore with useState + useEffect in Header so the remembered username is always null on the initial render (matching the server), then updated after hydration. Apply the same deferred pattern to useTheme, which was reading localStorage inside the useState initializer — a value the server can never produce, causing React to render different trees on server vs client.

Replace useSyncExternalStore with useState + useEffect in Header so the
remembered username is always null on the initial render (matching the
server), then updated after hydration. Apply the same deferred pattern
to useTheme, which was reading localStorage inside the useState
initializer — a value the server can never produce, causing React to
render different trees on server vs client.
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

Successfully merging this pull request may close these issues.

1 participant