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
53 lines (49 loc) · 1.67 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
import * as React from 'react';
import {Provider} from 'react-redux';
import {BrowserRouter, Route, Switch} from 'react-router-dom';
import {StaticRouter} from 'react-router';
import About from './views/About';
import Home from './views/Home';
import Contact from './views/Contact';
import Footer from './views/landmarks/Footer';
import Header from './views/landmarks/Header';
import IStore from './interfaces/IStore';
import ISagaStore from './interfaces/ISagaStore';
interface IProviderWrapperProps {
store: ISagaStore<IStore>;
isServerSide: boolean;
location?: string;
context?: any;
}
const RouterWrapper: React.StatelessComponent<IProviderWrapperProps> = (props: IProviderWrapperProps): JSX.Element => {
const Router = props.isServerSide ? StaticRouter : BrowserRouter;
return (
<Provider store={props.store}>
<Router
context={props.context}
location={props.location}
>
<div className="container">
<Header />
<Switch>
<Route
exact
path="/"
component={Home}
/>
<Route
path="/about"
component={About}
/>
<Route
path="/contact"
component={Contact}
/>
</Switch>
<Footer />
</div>
</Router>
</Provider>
);
};
export default RouterWrapper;