Skip to content

Instantly share code, notes, and snippets.

@milankinen
Created December 9, 2015 07:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save milankinen/29ab6c1ebed57cce56ff to your computer and use it in GitHub Desktop.
React ClientOnly component
/*
* <ClientOnly>
* <MyStuff />
* </ClientOnly>
*/
export default React.createClass({
getInitialState() {
return { allowRender: false }
},
componentDidMount() {
this.setState({allowRender: true})
},
render() {
return this.state.allowRender ? this.props.children : null
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment