-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathApp.js
More file actions
85 lines (74 loc) · 2.12 KB
/
App.js
File metadata and controls
85 lines (74 loc) · 2.12 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
// Import Style
import styles from './App.css';
// Import Components
import Helmet from 'react-helmet';
import Header from './components/Header/Header';
import Footer from './components/Footer/Footer';
// Import Actions
import { toggleAddPost } from './AppActions';
import { switchLanguage } from '../../modules/Intl/IntlActions';
let DevTools;
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line global-require
DevTools = require('./components/DevTools').default;
}
export class App extends Component {
constructor(props) {
super(props);
this.state = { isMounted: false };
}
componentDidMount() {
this.setState({isMounted: true}); // eslint-disable-line
}
toggleAddPostSection = () => {
this.props.dispatch(toggleAddPost());
}
render() {
return (
<div>
{this.state.isMounted && !window.devToolsExtension && process.env.NODE_ENV === 'development' && <DevTools />}
<div>
<Helmet
title="MERN Starter - Blog App"
titleTemplate="%s - Blog App"
meta={[
{ charset: 'utf-8' },
{
'http-equiv': 'X-UA-Compatible',
content: 'IE=edge',
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1',
},
]}
/>
<Header
switchLanguage={lang => this.props.dispatch(switchLanguage(lang))}
intl={this.props.intl}
toggleAddPost={this.toggleAddPostSection}
/>
<div className={styles.container}>
{this.props.children}
</div>
<Footer />
</div>
</div>
);
}
}
App.propTypes = {
children: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
// Retrieve data from store as props
function mapStateToProps(store) {
return {
intl: store.intl,
};
}
export default connect(mapStateToProps)(App);