@setTitle('test')
class Profile extends React.components {
}
function setTilte(title) {
return (target as WrappedComponent, name, descriptor) => {
return class extends React.Component {
updateTitle = (props) => {
// Check if the callback has returned something,
// and if so - update the title
const title = getTitle(props)
if(title) {
document.title = title
}
}
componentDidMount() {
this.updateTitle(this.props)
}
componentWillReceiveProps(props) {
this.updateTitle(props)
}
render() {
return <WrappedComponent {...this.props} />
}
}
}
}