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

style did not match server/client #52

Open
bart-sofomo opened this issue Mar 28, 2024 · 1 comment
Open

style did not match server/client #52

bart-sofomo opened this issue Mar 28, 2024 · 1 comment

Comments

@bart-sofomo
Copy link

bart-sofomo commented Mar 28, 2024

When using this library with nextjs 14 I'm getting:

Warning: Prop `style` did not match. 
Server: "position:absolute;top:0;left:0;right:0;bottom:0;overflow:scroll;-webkit-overflow-scrolling:touch;margin-right:0;margin-bottom:0" 
Client: "position:absolute;top:0;left:0;right:0;bottom:0;overflow:scroll;-webkit-overflow-scrolling:touch;margin-right:-15px;margin-bottom:-15px"

anyone run into this issue? Any fix?

@sam2x
Copy link

sam2x commented Jun 4, 2024

I got it too. In my case, the Scrollbars component is trying to apply a margin-right and margin-bottom of -16px on the client-side, but these styles doesn't apply server-side, thus causing the mismatch. Solution: doing a dynamic import of the scrollbar by using next/dynamics and setting server-side-rendering to off:

// ...import section 
import dynamic from 'next/dynamic';

// Dynamically import the Scrollbars component with SSR disabled
const Scrollbars = dynamic(
  () => import('react-custom-scrollbars-2').then((mod) => mod.Scrollbars),
  { ssr: false }
);
// your component code below...

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

No branches or pull requests

2 participants