This repository was archived by the owner on Nov 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRouterWrapper.jsx
55 lines (51 loc) · 1.87 KB
/
RouterWrapper.jsx
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
51
52
53
54
55
import * as React from 'react';
import {Provider} from 'react-redux';
import {ConnectedRouter} from 'react-router-redux';
import {createMemoryHistory} from 'history';
import {StaticRouter} from 'react-router';
import {Route, Switch, Redirect} from 'react-router-dom';
import AboutAsync from './views/about/AboutAsync';
import Home from './views/home/Home';
import Contact from './views/contact/Contact';
import FooterAsync from './views/landmarks/FooterAsync';
import Header from './views/landmarks/Header';
import NotFoundAsync from './views/errors/NotFoundAsync';
const RouterWrapper = (props) => {
const Router = props.isServerSide ? StaticRouter : ConnectedRouter;
const history = props.isServerSide ? createMemoryHistory() : props.history;
return (
<Provider store={props.store}>
<Router
context={props.context}
location={props.location}
history={history}
>
<div className="container">
<Header />
<Switch>
<Route
exact
path="/"
component={Home}
/>
<Route
path="/about"
component={AboutAsync}
/>
<Route
path="/contact"
component={Contact}
/>
<Redirect
from="/old-path"
to="/"
/>
<Route component={NotFoundAsync} />
</Switch>
<FooterAsync />
</div>
</Router>
</Provider>
);
};
export default RouterWrapper;