redfin / react-server

:rocket: Blazing fast page load and seamless navigation.
https://react-server.io/
Apache License 2.0
3.89k stars 184 forks source link

Add code splitting support to RootElement #963

Closed davidk107 closed 6 years ago

davidk107 commented 6 years ago

This introduces a componentLoader and childProps prop to RootElement. componentLoader takes in an asynchronous function that resolves to a component. RootElement will pause on rendering until componentLoader has been resolved. Using this with dynamic code loaders such as require.ensure or import() can result in having server side rendered sections without having to download the client side Javascript until later in the page loading process.

childProps will be additional props that can be passed to the resolved component. childProps are mainly used for sending down synchronous props. It's usage is not restricted to componentLoader and can be used with out it.

Examples and more detailed descriptions can be found under https://github.com/davidk107/react-server/tree/add-componentLoader-support/packages/react-server-examples/code-splitting