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*asReactfrom'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';
importAboutAsyncfrom'./views/about/AboutAsync';
importHomefrom'./views/home/Home';
importContactfrom'./views/contact/Contact';
importFooterAsyncfrom'./views/landmarks/FooterAsync';
importHeaderfrom'./views/landmarks/Header';
importNotFoundAsyncfrom'./views/errors/NotFoundAsync';
importISagaStorefrom'./stores/ISagaStore';
importModalHubfrom'./views/modals/ModalHub';
interfaceIProviderWrapperProps{
store: ISagaStore;
isServerSide: boolean;
location?: string;
context?: any;
history?: History;
}
constRouterWrapper: React.StatelessComponent<IProviderWrapperProps>=(props: IProviderWrapperProps): JSX.Element=>{
constRouter: any=props.isServerSide ? StaticRouter : ConnectedRouter;
consthistory: History=props.isServerSide ? null : props.history;
return(
<Providerstore={props.store}>
<Router
context={props.context}
location={props.location}
history={history}
>
<divclassName="container">
<Header/>
<Switch>
<Route
exact={true}
path="/"
component={Home}
/>
<Route
path="/about"
component={AboutAsync}
/>
<Route
path="/contact"
component={Contact}
/>
<Redirect
from="/old-path"
to="/"
/>
<Routecomponent={NotFoundAsync}/>
</Switch>
<FooterAsync/>
<ModalHub/>
</div>
</Router>
</Provider>
);
};
exportdefaultRouterWrapper;