Guest User

Untitled

a guest
Jun 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. export default title => ChildComponent =>
  4. class TitleChanger extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. oldTitle: document.title,
  9. };
  10. }
  11. componentDidMount() {
  12. document.title = title;
  13. }
  14.  
  15. componentWillUnmount() {
  16. document.title = this.state.oldTitle;
  17. }
  18.  
  19. render() {
  20. return <ChildComponent />;
  21. }
  22. };
Add Comment
Please, Sign In to add comment