-
Notifications
You must be signed in to change notification settings - Fork 12
/
App.js
36 lines (29 loc) · 842 Bytes
/
App.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
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import Helmet from 'react-helmet';
import { fetchPostsIfNeeded } from '../actions';
const DEFAULT_TITLE = 'React Boilerplate';
class App extends Component {
componentDidMount() {
const { dispatch } = this.props;
App.fetchData(dispatch);
}
render() {
return (
<div>
<Helmet titleTemplate={`%s | ${DEFAULT_TITLE}`} defaultTitle={DEFAULT_TITLE} />
{this.props.children}
{JSON.stringify(this.props.data)}
</div>
);
}
}
App.fetchData = function(dispatch) {
return dispatch(fetchPostsIfNeeded());
};
function mapStateToProps(state) {
return {
...state.posts
};
}
export default connect(mapStateToProps)(App);