forked from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (60 loc) · 1.7 KB
/
index.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
61
62
63
/**
*
* App.js
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import map from 'lodash/map';
import { compose } from 'redux';
import { Layout } from 'antd';
import { routeConfig } from '@app/routeConfig';
import { ThemeProvider } from 'styled-components';
import GlobalStyle from '@app/global-styles';
import { colors } from '@themes';
import Header from '@components/Header';
import For from '@components/For';
const theme = {
fg: colors.primary,
bg: colors.secondary
};
export function App({ location }) {
return (
<ThemeProvider theme={theme}>
<Header />
<Layout.Content>
<For
ParentComponent={props => <Switch {...props} />}
of={map(Object.keys(routeConfig))}
renderItem={(routeKey, index) => {
const Component = routeConfig[routeKey].component;
return (
<Route
exact={routeConfig[routeKey].exact}
key={index}
path={routeConfig[routeKey].route}
render={props => {
const updatedProps = {
...props,
...routeConfig[routeKey].props
};
return <Component {...updatedProps} />;
}}
/>
);
}}
/>
<GlobalStyle />
</Layout.Content>
</ThemeProvider>
);
}
App.propTypes = {
location: PropTypes.object
};
export default compose(withRouter)(App);