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

fix: Hydration mismatch on table collection #604

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alaycock
Copy link

@alaycock alaycock commented Jan 13, 2025

Description

There is a mismatch between the styles applied to table collection between server render and hydration. The client depends on the window width, which causes the mismatch.

Hydration mismatches result in unpredictable behaviour. In this case, the server style is being incorrectly preserved. The table initially renders with the incorrect width, then jumps to the correct position when the screen is resized.

The problem:

Screen.Recording.2025-01-12.at.8.44.48.PM.mov

The proposed fix applies a static style when rendering on the server to prevent the jump, but after mounting, the correct style is then applied. I opted to use visibility: hidden for the server state, because otherwise the table immediately performing a transition on page load. It's a brief flash, but less visually impactful than a transition. My approach is opinionated, so I'm open to feedback if you have other suggestions.

After the fix is applied:

Screen.Recording.2025-01-12.at.8.46.05.PM.mov

Notion Test Page ID

https://adaminthehills.notion.site/174d424ea49f805cabc7ec5d4a5a2bfe?v=4a4959c0aa884661a01793045a5d421c&pvs=4

Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-notion-x ✅ Ready (Inspect) Visit Preview Jan 25, 2025 7:59pm
react-notion-x-minimal-demo ✅ Ready (Inspect) Visit Preview Jan 25, 2025 7:59pm

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.

2 participants