Answer the question
In order to leave comments, you need to log in
How to work with lazy loading in Nextjs React?
When developing on pure react, I can set the lazy loading of components in the router like this
const NotFoundPage = lazy(() => import('containers/NotFoundPage'));
const HomePage = lazy(() => import('containers/HomePage'));
const Stores = lazy(() => import('containers/StoresPage'));
export default () => (
<Router>
<Suspense fallback={<Preloader />}>
<Switch>
<Route exact path={routes.HOME} component={HomePage} />
<Route exact path={routes.STORES} component={Stores} />
<Route component={NotFoundPage} />
</Switch>
</Suspense>
</Router>
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question