Fix page title if page type does not change

This commit is contained in:
Tom Raithel
2017-03-21 21:48:17 +01:00
parent 36985267c6
commit 7a5b88680c

View File

@@ -1,10 +1,21 @@
import React from 'react';
const callSetTitle = (props) => {
if (typeof props.onSetTitle === 'function' && props.title) {
props.onSetTitle(props.title);
}
};
class SetTitle extends React.Component {
constructor(props) {
super(props);
if (typeof props.onSetTitle === 'function' && props.title) {
props.onSetTitle(props.title);
callSetTitle(props);
}
componentWillReceiveProps(nextProps) {
if (nextProps.title !== this.props.title) {
callSetTitle(nextProps);
}
}