Skip to content

Instantly share code, notes, and snippets.

@mariusandra
Created December 1, 2016 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariusandra/1550ffae609b7b91549f15447e73a030 to your computer and use it in GitHub Desktop.
Save mariusandra/1550ffae609b7b91549f15447e73a030 to your computer and use it in GitHub Desktop.
react-helmet with react_on_rails server side rendering
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