Created
December 1, 2016 14:38
-
-
Save mariusandra/1550ffae609b7b91549f15447e73a030 to your computer and use it in GitHub Desktop.
react-helmet with react_on_rails server side rendering
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, { Component, PropTypes } from 'react' | |
import ReactHelmet from 'react-helmet' | |
class PlainComponent extends Component { | |
render () { | |
return null | |
} | |
} | |
export default class Helmet extends Component { | |
static propTypes = { | |
helmet: PropTypes.object | |
} | |
render () { | |
const { helmet } = this.props | |
if (typeof document === 'undefined') { | |
return <PlainComponent /> | |
} else { | |
return <ReactHelmet {...helmet} /> | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment