Fix page title if page type does not change
This commit is contained in:
@@ -1,10 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
|
||||||
|
const callSetTitle = (props) => {
|
||||||
|
if (typeof props.onSetTitle === 'function' && props.title) {
|
||||||
|
props.onSetTitle(props.title);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SetTitle extends React.Component {
|
class SetTitle extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
if (typeof props.onSetTitle === 'function' && props.title) {
|
callSetTitle(props);
|
||||||
props.onSetTitle(props.title);
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if (nextProps.title !== this.props.title) {
|
||||||
|
callSetTitle(nextProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user