stratiformltd / react-loadable-visibility

A wrapper around react-loadable and @loadable/component to load elements once they are visible on the page.
BSD 3-Clause "New" or "Revised" License
1.01k stars 31 forks source link

Always render all contents during SSR? #9

Closed fikriauliya closed 6 years ago

fikriauliya commented 6 years ago

Inspecting the raw HTML returned from SSR, it seems this library doesn't return the not-yet-visible content (e.g. Footer) as part of SSR response. In our use case, we need to render all LoadableVisibility-wrapped components during SSR. Is it currently possible?

tazsingh commented 6 years ago

Yes it will be the same way that you would render react-loadable or loadable-components from the server. react-loadable-visibility will just return the underlying component on the server where the IntersectionObserver API is not available - https://github.com/stratiformltd/react-loadable-visibility#how-does-this-work

I've used this approach with react-loadable on my own website which is statically rendered and you can refer to the code there as an example - https://github.com/stratiformltd/website

Hope that helps!