Routes.jsx 935 Bytes
Newer Older
1 2 3 4 5 6 7 8
import React, { Suspense, lazy } from "react";
import { Route, withRouter, Switch } from "react-router-dom";
import { NavBar } from "Components";

const Home = lazy(() => import("../Components/Pages/HomePage"));
const Dhaynes = lazy(() => import("../Components/Pages/DhaynesPage"));
const About = lazy(() => import("../Components/Pages/AboutPage"));
const DebugCRUD = lazy(() => import("../Components/Pages/DebugCRUD"));
9 10

const NavBarWithRouter = withRouter(props => <NavBar {...props} />);
Zach Osman's avatar
Zach Osman committed
11

12 13 14
const Routes = () => (
  <div>
    <NavBarWithRouter />
15 16 17 18 19 20 21 22 23
    <Suspense fallback={<div>Loading...</div>}>
      <Switch>
        <Route path="/" exact component={Home} />
        <Route path="/dhaynes" component={Dhaynes} />
        <Route path="/about" component={About} />
        <Route path="/debug" component={DebugCRUD} />
        <Route render={() => <div>404</div>} />
      </Switch>
    </Suspense>
24 25
  </div>
);
Zach Osman's avatar
Zach Osman committed
26 27

export default Routes;