I am trying to implement an application that has 10-15 pages. That works with react-router well but I should use react-loadable to have a Spinner and loading effect ...
But how can I import router components inside the loadable ?
I should create one const variable for each component ?
Like this :
const Home = Loadable({
loader: () => import('./Home'),
loading: Loading,
});
const News = Loadable({
loader: () => import('./News'),
loading: Loading,
});
const Gallery = Loadable({
loader: () => import('./Gallery'),
loading: Loading,
});
class App extends React.Component {
render() {
return (
<Router>
<Route exact path="/" component={Home} />
<Route path="/news" component={News} />
<Route path="/gallery" component={Gallery} />
</Router>
)
}
}
Or it's possible with other tricks ?