Can someone explain what exactly is happening behind the scene. I’m particularly confused about the difference between using the onPageLoad on client vs using it on server.
especially on client side, I mean… a server side rendering on the client side??? what does that mean?
onPageLoad is for server-side only. On client you can use your client router or a package like ‘history’ on npm to listen to the URL change client-side
Note also that the client example does not end up calling any methods of the sink object, because ReactDOM.render has its own similar API. In fact, you are not even required to use the onPageLoad API on the client, if you have your own ideas about how the client should do its rendering.
But I’m just very confused. Especially on client side, what does it mean “server side rendering on the client side”? and what is the difference between calling it on server and client?
My question is more towards understanding the concept.
From what I get, the server will send a server-rendered version of your HTML first, then it will send some javascript files to your client.
That means the user will see some HTML/CSS (without javascript) first, then there will be the ‘data rehydration’ phase which means that full javascript is enabled.
So at this time the HTML sent by the server is actually overriden by the HTML/CSS/JS of the client, which takes over.