forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
60 lines (53 loc) · 1.31 KB
/
App.jsx
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, { PropTypes } from 'react';
import { contain } from 'thundercats-react';
import { Row } from 'react-bootstrap';
import { Nav } from './components/Nav';
import { Footer } from './components/Footer';
export default contain(
{
store: 'appStore',
fetchAction: 'appActions.getUser',
getPayload(props) {
return {
isPrimed: !!props.username
};
}
},
React.createClass({
displayName: 'FreeCodeCamp',
propTypes: {
children: PropTypes.node,
points: PropTypes.number,
picture: PropTypes.string,
title: PropTypes.string,
username: PropTypes.string
},
componentDidMount() {
const title = this.props.title;
this.setTitle(title);
},
componentWillReceiveProps(nextProps) {
if (nextProps.title !== this.props.title) {
this.setTitle(nextProps.title);
}
},
setTitle(title) {
const doc = typeof document !== 'undefined' ? document : {};
doc.title = title;
},
render() {
const { username, points, picture } = this.props;
const navProps = { username, points, picture };
return (
<div>
<Nav
{ ...navProps }/>
<Row>
{ this.props.children }
</Row>
<Footer />
</div>
);
}
})
);