ueno-llc/starter-kit-universally

Why so many rerenders?

jdwillemse opened this issue · 2 comments

I've noticed that the entire app is rendered twice on the server and twice more on the client. This seems to be a waste of resources. If the content is all there and rendered on the server, why is a client-side render happening?

To replicate, add some logging to MainApp.js and observe that server and client logs repeat 4 times.

This is because of react-async-bootstrapper, it walks the tree and renders to resolve all lazy loaded components then does a final render.

This can be solved with react suspense in the future

The client should not render twice however, so if you can share your snippet that would help.

Thanks

I don't have a snippet; I tested with the blank code that's in this repo. I literally just added a console.log('bla') in the MainApp function and saw it logged twice on the server and twice in the client. It is also logged twice for the service worker but I assumed that's correct.