Created
December 9, 2015 07:55
-
-
Save milankinen/29ab6c1ebed57cce56ff to your computer and use it in GitHub Desktop.
React ClientOnly component
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
/* | |
* <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