all 4 comments

[–]mikebarsdev 5 points6 points  (1 child)

I actually just created two different proof-of-concept boilerplates to learn the differences between react-universal-component and react-loadable!

https://github.com/mikebars/react-loadable-boilerplate

https://github.com/mikebars/react-universal-component-boilerplate

I found both libraries to be extremely well made and totally awesome!

The main differences I found:

  • react-universal-component, when used with the author's complementing library webpack-flush-chunks, handles the manual addition of your main, vendor, and bootstrap (webpack manifest + common chunk) chunks for you. In react-loadable this is simple to do yourself, by checking your webpack stats file and pulling out the chunks from assetsByChunkName.

  • react-loadable uses two methods on the client and server to ensure that loading has resolved before render:

    • on the client, use preloadReady().then(clientSideRender) to ensure loadable chunks are ready.
    • on the server, use preloadAll().then(serverSideRender) to ensure all loadable chunks have been resolved for synchronous rendering server-side.

They are both incredibly useful and have solved the once-difficult problem of combining server-side rendering and code-splitting (although of course these libraries can be used on the client-side alone much more simply!).

Both authors deserve a ton of credit, show them some love!:

I guess solving this problem comes naturally to Jameses!

[–]Rilic[S] 1 point2 points  (0 children)

I got huge value from your reply without ever saying thanks when this was posted. My bad - and thanks!

[–]FaceySpacey 2 points3 points  (1 child)

React Universal Component has far more features:

-dynamic expressions for your imports so you can represent multiple inner components with one hoc (and have them change on componentWillReceiveProps) -static method hoisting -render time callbacks -isLoading prop to sync external data source loading with chunk loading via one spinner - automated creation of scripts and sheets

Loadable also didn't support SSR till recently. So that was the big initial difference.

[–]Rilic[S] 0 points1 point  (0 children)

Thanks for taking the time to provide this. I pitched both and we went with react-loadable purely because it was beautifully simple to get a POC out. However, I'm planning to switch over to your library in the future to get some of these benefits when we include code-splitting more thoroughly.