Created
May 12, 2017 09:30
-
-
Save Qquanwei/e96fc483715e39f5964a521c5d57270b to your computer and use it in GitHub Desktop.
react withTitle. change title when switch component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import createReactClass from 'create-react-class' | |
import cu from 'lodash/curry' | |
export default cu(function (title, Component) { | |
let oriTitle = document.title | |
return createReactClass({ | |
componentWillMount () { | |
oriTitle = document.title | |
document.title = title | |
}, | |
componentWillUnmount () { | |
document.title = oriTitle | |
}, | |
render () { | |
return <Component {...this.props}/> | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usag:
or