pokemon.tsx 909 B

123456789101112131415161718192021222324252627282930
  1. import React, {lazy, Suspense} from 'react';
  2. import PropTypes from 'prop-types';
  3. import {Route, Switch, RouteComponentProps} from 'react-router-dom';
  4. const PokemonShow = lazy((): Promise<any> => import('./pokemon/show'));
  5. const PokemonIndex = lazy((): Promise<any> => import('./pokemon/index'));
  6. const RelayTest = lazy((): Promise<any> => import('./relay_test'));
  7. import NotFound from './not_found';
  8. function Pokemon({match}: RouteComponentProps<void>): React.FunctionComponentElement<void> {
  9. return (
  10. <>
  11. <Suspense fallback={<div>Loading...</div>}>
  12. <Switch>
  13. <Route component={RelayTest} exact path={`${match.path}/:id`} />
  14. <Route component={RelayTest} exact path={`${match.path}`} />
  15. <Route component={NotFound} />
  16. </Switch>
  17. </Suspense>
  18. </>
  19. );
  20. }
  21. Pokemon.propTypes = {
  22. match: PropTypes.object.isRequired,
  23. };
  24. export default Pokemon;