-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Error while using randomness for inline styling #1173
Comments
@manuelro The warning is expected behavior. Yes the different random RGB values from server to client are causing the issue. If you're interested, you can learn about universal react here. |
Try setting the colour outside of the components for the first render, and only generating if it doesn't exist (on the server). |
Thanks for the advice. I'll give it a try. |
Closing as this is not an issue produced by Next.js, feel free to re-open if needed ❤️ |
There is some weird error warning about issues with server and client sides rendering not being the same. The issue shows up only if I use
rgb
colors in CSS-in-JS for inline styling.The error:
If I replace the color from rgb to any named-color ('blue', 'red', etc.), the warning disappears.
The code
And I think the differences between the client color and the server color has to do with randomness. My script is generating a random color based on
hsl
and translated torgb
, this is how this is intended to be. Is there any chance the random number generated on the server is being overridden by the random number generated on the client? If so, is this the intended behaviour? I know isomorphic JS is something hard to deal with. Any advice would be greatly appreciated.The text was updated successfully, but these errors were encountered: