/map-title-from-props.jsx Secret
Last active
September 22, 2016 22:30
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 Helmet from 'react-helmet' | |
const mapTitleFromProps = WrappedComponent => props => { | |
let definedTitle | |
if (typeof props.route.title === 'function') { | |
definedTitle = props.route.title(props) | |
} else if (typeof props.route.title === 'string') { | |
definedTitle = props.route.title | |
} | |
const title = definedTitle ? `${definedTitle} | Nomos` : 'Nomos' | |
return ( | |
<span> | |
<Helmet title={title} /> | |
<WrappedComponent {...props} /> | |
</span> | |
) | |
} | |
export default mapTitleFromProps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment