App.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import React, {lazy, Suspense} from 'react';
  2. import {Router, Route, Link, Switch} from 'react-router-dom';
  3. import {hot} from 'react-hot-loader/root';
  4. import history from './history';
  5. import ApplicationLayout from './components/layout/ApplicationLayout';
  6. const Pokemon = lazy((): Promise<any> => import('./components/pages/Pokemon'));
  7. const NotFound = lazy((): Promise<any> => import('./components/pages/NotFound'));
  8. const TestComponent = lazy((): Promise<any> => import('./components/TestComponent'));
  9. import './assets/stylesheets/app.scss';
  10. function App(): React.ReactElement {
  11. return (
  12. <Router history={history}>
  13. <ApplicationLayout>
  14. <Suspense fallback={<div>Loading...</div>}>
  15. <Switch>
  16. <Route component={TestComponent} exact path='/' />
  17. <Route component={Pokemon} path='/pokemon' />
  18. <Route component={NotFound} />
  19. </Switch>
  20. <p>
  21. <Link to='/pokemon'>Show me the pokemon!</Link>
  22. </p>
  23. </Suspense>
  24. </ApplicationLayout>
  25. </Router>
  26. );
  27. }
  28. export default hot(App);