Based on react-router-proxy-loader and react-proxy-loader, adapted for react-router route handlers.
npm install react-router-loader --save-devWhich version to use depends on your version of react-router
| react-router | react-router-loader |
|---|---|
| 0.13.x | 0.3.x |
| 1.x | 0.4.x |
| 2.x and above | 0.5.x |
Use when requiring the component for a Route, and the component will only be loaded when the route is rendered.
<Route component={require('react-router!./Component')} />You can give the chunk a name with the name query parameter:
<Route component={require('react-router?name=chunkName!./Component')} />