Nextjs mix SSR and client data in components #13498
-
I faced the situation when the same component shows mixed data when randomisation involved, html get jumbled data partially from SSR and partially from client rendering. Here is the code :
The result is following. SSR :
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can not use randomization like this. You should probably generate a random number in the getStaticProps and send that to the client so the server and the client renders the same data. If you wish to render something random on the client only, you should use useEffect and set a value on a useState property Does that make sense? |
Beta Was this translation helpful? Give feedback.
You can not use randomization like this. You should probably generate a random number in the getStaticProps and send that to the client so the server and the client renders the same data.
If you wish to render something random on the client only, you should use useEffect and set a value on a useState property
Does that make sense?