freeCodeCamp/common/app/App.jsx

61 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-06-18 04:04:28 +00:00
import React, { PropTypes } from 'react';
import { contain } from 'thundercats-react';
2015-07-04 15:16:42 +00:00
import { Row } from 'react-bootstrap';
2015-06-18 04:04:28 +00:00
2015-07-04 00:46:58 +00:00
import { Nav } from './components/Nav';
import { Footer } from './components/Footer';
2015-06-18 04:04:28 +00:00
export default contain(
{
store: 'appStore',
fetchAction: 'appActions.getUser',
getPayload(props) {
return {
isPrimed: !!props.username
};
}
},
React.createClass({
displayName: 'FreeCodeCamp',
2015-06-18 04:04:28 +00:00
propTypes: {
2015-07-25 04:54:19 +00:00
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;
},
2015-06-18 04:04:28 +00:00
render() {
2015-07-25 04:54:19 +00:00
const { username, points, picture } = this.props;
const navProps = { username, points, picture };
return (
<div>
2015-07-25 04:54:19 +00:00
<Nav
{ ...navProps }/>
<Row>
{ this.props.children }
</Row>
<Footer />
</div>
);
}
})
);