-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-App-with-router.js
60 lines (52 loc) · 1.49 KB
/
react-App-with-router.js
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
import React from 'react'
import { Route } from 'react-router-dom'
import { withRouter } from 'react-router-dom'
import { withStyles } from '@material-ui/core/styles'
import { connect } from 'react-redux'
import compose from 'recompose/compose'
import AppBar from '../components/ZnAppBar'
import AppDrawer from '../components/ZnAppDrawer'
import { routes } from '../../routes'
import '../styles/app.css'
const styles = theme => ({
root: {
flexGrow: 1,
zIndex: 1,
overflow: 'hidden',
position: 'relative',
height: '100%'
},
appBody: {
left: -50,
},
content: {
flexGrow: 1,
backgroundColor: theme.palette.background.default,
// padding: theme.spacing.unit * 3,
},
});
const App = (props) => {
const { classes } = props;
return (
<div className={classes.root}>
<AppBar />
<AppDrawer entitlements={props.entitlements} />
<main className={classes.content}>
{routes.map((route, index) => (
<Route
key={index}
exact={route.exact}
path={route.path}
component={route.main}
/>
))}
</main>
</div>
)
}
const mapStateToProps = state => {
return {
entitlements: state.common.entitlements
}
}
export default compose(withRouter, withStyles(styles), connect(mapStateToProps))(App);