Continued porting to React

This commit is contained in:
Colin McLeod
2016-01-11 18:04:38 -08:00
parent ab0019424f
commit 653cb30dd9
39 changed files with 1865 additions and 1420 deletions

View File

@@ -1,17 +1,25 @@
import React from 'react';
import shallowEqual from '../utils/shallowEqual';
/**
* @class Abstract Page
*/
export default class Page extends React.Component {
static contextTypes = {
route: React.PropTypes.object.isRequired,
language: React.PropTypes.object.isRequired
language: React.PropTypes.object.isRequired,
sizeRatio: React.PropTypes.number.isRequired
};
static propTypes = {
currentMenu: React.PropTypes.any
};
/**
* Created an instance of a Page. This is an abstract class.
* @param {object} props Properties
*/
constructor(props) {
super(props);
@@ -23,16 +31,34 @@ export default class Page extends React.Component {
});
}
/**
* Translated components are 'pure' components that only render when
* props, state, or context changes. This method performs a shallow comparison to
* determine change.
*
* @param {object} nextProps
* @param {objec} nextState
* @param {objec} nextContext
* @return {boolean} True if props, state, or context has changed
*/
shouldComponentUpdate(nextProps, nextState, nextContext) {
return !shallowEqual(this.props, nextProps)
|| !shallowEqual(this.state, nextState)
|| !shallowEqual(this.context, nextContext)
}
/**
* Update the window title upon mount
*/
componentWillMount() {
document.title = this.state.title || 'Coriolis';
}
/**
* Updates the title upon change
* @param {Object} newProps Incoming properties
* @param {Object} newState Incoming state
*/
componentWillUpdate(newProps, newState) {
document.title = newState.title || 'Coriolis';
}