pokemon.jsx 632 B

123456789101112131415161718192021222324
  1. import React, {lazy, Suspense} from 'react';
  2. import {Route, Switch} from 'react-router-dom';
  3. const PokemonShow = lazy(() => import('./pokemon/show'));
  4. const PokemonIndex = lazy(() => import('./pokemon/index'));
  5. import NotFound from './not_found';
  6. function Pokemon({match}) {
  7. return (
  8. <>
  9. <Suspense fallback={<div>Loading...</div>}>
  10. <Switch>
  11. <Route exact path={`${match.path}/:id`} component={PokemonShow} />
  12. <Route exact path={`${match.path}`} component={PokemonIndex} />
  13. <Route component={NotFound} />
  14. </Switch>
  15. </Suspense>
  16. </>
  17. );
  18. }
  19. export default Pokemon;