I have a route component that I want to download async with webpack:
<Route path="dashboard" getComponent={(location, cb) => { require.ensure([], (require) => { cb(null, require('./Containers/Dashboard')); }); }}>
These are many templates if you have many other routes that require asynchronous loading. So I thought, let me reorganize this into a helper method:
const loadContainerAsync = route => (location, cb) => { require.ensure([], (require) => { cb(null, require('../Containers/' + route)); }); }; // much 'nicer syntax' <Route path="dashboard" getComponent={loadContainerAsync('Dashboard')} />
Apparently, when I look at the network tab in firefox-devtools, the behavior of the loadContainerAsync function does not work correctly. Any idea what could be wrong with my loadContainerAsync function?
source share