From 7a5b88680c19d1495b6a08109e4c8d323a95356c Mon Sep 17 00:00:00 2001 From: Tom Raithel Date: Tue, 21 Mar 2017 21:48:17 +0100 Subject: [PATCH] Fix page title if page type does not change --- js/components/SetTitle.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/components/SetTitle.js b/js/components/SetTitle.js index 6d69e40..cca10ec 100644 --- a/js/components/SetTitle.js +++ b/js/components/SetTitle.js @@ -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); } }