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

Console warnings when using SSR #260

Open
mledwards opened this issue Jan 4, 2023 · 5 comments
Open

Console warnings when using SSR #260

mledwards opened this issue Jan 4, 2023 · 5 comments

Comments

@mledwards
Copy link

Hello. I'm using Next.js which has server side rendering (SSR) built in (e.g. loads from the server on page refresh).

I'm getting some console warnings when the page is being SSR loaded, as the numbers are not matching between the server and the client.

Here's one of the warnings.

Does anyone know if there's a way of fixing this?

Warning: Prop `dx` did not match. Server: "-31.536962440920004" Client: "-31.536962440920007"
text
ReactMinimalPieChartLabel@webpack-internal:///./node_modules/react-minimal-pie-chart/dist/index.js:99:23
svg
ReactMinimalPieChart@webpack-internal:///./node_modules/react-minimal-pie-chart/dist/index.js:329:38
@toomuchdesign
Copy link
Owner

Hi @mledwards, would you mind putting together e repro?

@mledwards
Copy link
Author

mledwards commented Jan 10, 2023

Hi @toomuchdesign, thank you for taking a look.

Here's the repo: https://github.com/mledwards/react-minimal-pie-chart-example-in-next

This should replicate the issue above in the console every time you refresh the index page (SSR).

My best guess is that the way server side JS calculates float numbers is slightly different to the way client side JS calculates them, and after 15 decimals points it deviates.

Maybe the decimal place could be capped at 15 points so both the server and the client return the same number? Not sure if this would have any adverse affects on the rendering?

@toomuchdesign
Copy link
Owner

Thanks @mledwards! What browsers/OS you're experiencing this issue with? Can you reproduce consistently on different browsers?

@toomuchdesign
Copy link
Owner

I assume it's an issue about how different JS engines handle float numbers. V8 seems to work consistently across Node and Chromium/Blink browsers. Not totally sure we should address this in user land, but It let's discuss possible solutions/workaround.

The glitch here is that non-Chromium/blink users might perform and extra render loop after mount which I'd be glad to avoid.

@mledwards
Copy link
Author

I'm on a Mac and can see it on Firefox and Safari, but not on Chrome and Edge. Sorry, I should have mentioned that in the original message.

Maybe I'll try and suppress that Next.JS warning.

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