1import React, {Suspense} from 'react;
2const ProfilePage = React.lazy(() => import('./ProfilePage')); // Lazy-loaded
3
4// Show a spinner while the profile [data fetching] is loading
5<Suspense fallback={<Spinner />}>
6 <ProfilePage />
7</Suspense>
1import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
2import React, { Suspense, lazy } from 'react';
3
4const Home = lazy(() => import('./routes/Home'));
5const About = lazy(() => import('./routes/About'));
6
7const App = () => (
8 <Router>
9 <Suspense fallback={<div>Chargement...</div>}>
10 <Switch>
11 <Route exact path="/" component={Home}/>
12 <Route path="/about" component={About}/>
13 </Switch>
14 </Suspense>
15 </Router>
16);