I am now experiencing a problem with react SSR. Basically I am building a universal React App, upon sending the initial request from the browser, server should prepare all the necessary data and call renderToString() to pass the rendered HTML to user.
In my server side code, I have something like:
fetchInitialData().then((response) => renderToString(...))
As you can see it, the server will wait fetchInitialData to be finished then it can send the rendered HTML. However, the problem here is that the fetchInitialData takes a long time to finish, that means on the client side user will see a blank screen until server finishes that initial API call.
My question is is there any way for server to send a loading page to user, when it finishes the API call, update the loading screen with the actual data?
====== One solution I can think of is to let server straight send the loading page to user, then user calls that API in componentDidMount() Please advise if you have a better one