Skip to content

Instantly share code, notes, and snippets.

@sllvn sllvn/map-title-from-props.jsx Secret
Last active Sep 22, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.