Suspense
Lazy Components
import React, { Suspense } from 'react';
import Loading from './Loading';
const PokemonList = React.lazy(() => import('./List/PokemonList'));
const StarWarsList = React.lazy(() => import('./List/StarWarsList'));
function App(props) {
return (
<Suspense fallback={<Loading />}>
{/* We use PokemonList like any imported component */}
{props.route === 'pokemon' && <PokemonList />}
{props.route === 'starwars' && <StarWarsList />}
</Suspense>
);
}Future
Last updated