I have the following code, where boxes.jsx
should be dynamically loaded when a particular route is hit:
...
import Loadable from 'react-loadable';
const LoadableBoxes = Loadable({
loader: () => import('../pages/boxes/boxes.jsx'),
loading: () => <div>Loading</div>
});
class AppWrapperLoggedInContainer extends Component {
...
render() {
return (
<AppWrapperLoggedIn>
<Switch>
<Route exact path={core.urls.pages.pathBoxes()} component={restricted(LoadableBoxes)} />
<Route exact path={core.urls.pages.pathOrganiser()} component={restricted(Organizer)} />
<Route component={Error404} />
</Switch>
</AppWrapperLoggedIn>
);
}
}
However, I can see that the file is being bundled by Webpack in the main app.*.js
bundle and a separate bundle is not being dynamically loaded when I hit that route. Any ideas why this is not working - I have checked the codebase and the boxes.jsx
file in not being imported anywhere else?