Pokemon.tsx 754 B

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