-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[MediaQueryProvider] Fix SSR hydration issues #12824
Conversation
f7ed2f3
to
fdce8e8
Compare
I think there is an unrelated issue with Next.js + Node v23.1.0 causing the CI failures (vercel/next.js#47394 (comment)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩 'd & lgtm
fdce8e8
to
b9fe9e0
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/[email protected] ### Patch Changes - [#12824](#12824) [`85c5bb7b4`](85c5bb7) Thanks [@moraleslevi](https://github.com/moraleslevi)! - Fix hydration issues with SSR ## [email protected] ### Minor Changes - [#12662](#12662) [`5bb85b547`](5bb85b5) Thanks [@heyjoethomas](https://github.com/heyjoethomas)! - Removes unnecessary new badges from navigation ### Patch Changes - [#12739](#12739) [`af15611a6`](af15611) Thanks [@sarahill](https://github.com/sarahill)! - Updated common action guidelines - [#12806](#12806) [`57e6cbe71`](57e6cbe) Thanks [@IlanaB](https://github.com/IlanaB)! - Fixed a typo in the common actions overview - Updated dependencies \[[`85c5bb7b4`](85c5bb7)]: - @shopify/[email protected] Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
WHY are these changes introduced?
Fixes #11886
Server-side rendering defaults to
isNavigationCollapsed
beingfalse
, which causes a React hydration issue when rendered on the client at smaller breakpoints (where the value evaluates astrue
).WHAT is this pull request doing?
This modifies the initial render state of
isNavigationCollapsed
to match the server-side rendered value (false
) and relies on the existinguseEffect
to update the value on the client-side after hydration.Before change - React hydration errors at small breakpoints
ssr-before.mp4
After change - No React hydration errors at small breakpoints
ssr-after.mp4
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes