Skip to content

Instantly share code, notes, and snippets.

@sllvn
Last active September 22, 2016 22:30
Show Gist options
  • Save sllvn/0bb5f5e88718944f514b99c064be64b1 to your computer and use it in GitHub Desktop.
Save sllvn/0bb5f5e88718944f514b99c064be64b1 to your computer and use it in GitHub Desktop.
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