mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 22:55:35 +00:00
Continued porting to React
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user