ModusCreateOrg/react-dynamic-route-loading-es6

Server Side rendering example?

tconroy opened this issue · 2 comments

This medium post and this repo are the cleanest examples of code splitting I've found, so thank you!

One thing I'd like to request is an example of a server side implementation, where the initial state is set by the server and returned to the client with the appropriate bundles.

grgur commented

Thanks @tconroy. I fully agree. Let's see if we can have someone help out

@tconroy I could make SSR work by changing a little bit the getComponent functions. It works in my setup, I didn't try it in this project.

getComponent(location, cb) {
  if (process.env.IS_BROWSER) {
    System.import('pages/Home').then(loadRoute(cb)).catch(errorLoading);
  } else {
    cb(null, require('pages/Home').default))
  }
}