import React from 'react' ; export default class DocumentTitle extends React . Component { componentDidUpdate ( prevProps ) { if ( prevProps . title !== this . props . title ) { this . setTitle ( this . props . title ) ; } } componentDidMount ( ) { this . setTitle ( this . props . title ) ; } getTitle ( ) { return document . title ; } setTitle ( title ) { document . title = title ; } render ( ) { return this . props . children ; } }