aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.tsx
blob: 19ba6a6cee186a400d346ba2b89626a4895e03a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/** @jsx jsx */
/** @global location */
import { jsx, Global } from "@emotion/core";

import {
  BrowserRouter as Router,
  Route,
  Switch
} from "react-router-dom";

import { CSSTransition, TransitionGroup } from "react-transition-group";

import LandingPage from "./pages/LandingPage";
import FormPage from "./pages/FormPage";
import CallbackPage from "./pages/CallbackPage";

import globalStyles from "./globalStyles";

const routes = [
  { path: "/", Component: LandingPage },
  { path: "/form/:id", Component: FormPage},
  { path: "/callback", Component: CallbackPage }
]

function App() {
  return (
    <div>
      <Global styles={globalStyles}/>
      <Router>
        <Route render={({ location }) => (
          <TransitionGroup>
            <CSSTransition
              key={location.pathname}
              classNames="fade"
              timeout={300}
            >
              <Switch location={location}>
                {routes.map(({path, Component}) => (
                  <Route key={path} exact path={path} component={Component}/>
                ))}
              </Switch>
            </CSSTransition>
          </TransitionGroup>
        )}/>
      </Router>
    </div>
  );
};

export default App;