App.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from 'react';
  2. import {
  3. BrowserRouter as Router,
  4. Switch,
  5. Route,
  6. } from 'react-router-dom';
  7. import 'App.css';
  8. import FishTable from 'Fishes';
  9. import InsectTable from 'Insects';
  10. import Navbar from 'components/Navbar';
  11. const routes = [
  12. {
  13. path: "/",
  14. name: 'home',
  15. exact: true,
  16. component: () => <h2>Home</h2>
  17. },
  18. {
  19. path: "/fishes",
  20. name: 'fishes',
  21. component: FishTable
  22. },
  23. {
  24. path: "/insects",
  25. name: 'insects',
  26. component: InsectTable
  27. }
  28. ];
  29. const App: React.FunctionComponent = () => {
  30. return (
  31. <div className="cc-app">
  32. <Router>
  33. <Navbar routes={routes} />
  34. <div className="cc-content">
  35. <Switch>
  36. {
  37. routes.map((route, key) => (
  38. <Route key={key} path={route.path} exact={route.exact}>
  39. <route.component/>
  40. </Route>
  41. ))
  42. }
  43. </Switch>
  44. </div>
  45. </Router>
  46. <div className="cc-footer"></div>
  47. </div>
  48. );
  49. }
  50. export default App;