This repository was archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRouterWrapper.tsx
executable file
·64 lines (60 loc) · 2.19 KB
/
RouterWrapper.tsx
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
56
57
58
59
60
61
62
63
64
import * as React from 'react';
import {Provider} from 'react-redux';
import {ConnectedRouter} from 'connected-react-router';
import {History} from 'history';
import {Redirect, Route, StaticRouter, Switch} 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';
import ISagaStore from './stores/ISagaStore';
import ModalHub from './views/modals/ModalHub';
interface IProviderWrapperProps {
store: ISagaStore;
isServerSide: boolean;
location?: string;
context?: any;
history?: History;
}
const RouterWrapper: React.StatelessComponent<IProviderWrapperProps> = (props: IProviderWrapperProps): JSX.Element => {
const Router: any = props.isServerSide ? StaticRouter : ConnectedRouter;
const history: History = props.isServerSide ? null : props.history;
return (
<Provider store={props.store}>
<Router
context={props.context}
location={props.location}
history={history}
>
<div className="container">
<Header />
<Switch>
<Route
exact={true}
path="/"
component={Home}
/>
<Route
path="/about"
component={AboutAsync}
/>
<Route
path="/contact"
component={Contact}
/>
<Redirect
from="/old-path"
to="/"
/>
<Route component={NotFoundAsync} />
</Switch>
<FooterAsync />
<ModalHub />
</div>
</Router>
</Provider>
);
};
export default RouterWrapper;