Last active
August 29, 2015 14:08
-
-
Save stevoland/e127f5e9854d0862701e to your computer and use it in GitHub Desktop.
shouldRenderForClientMixin
This file contains hidden or 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
var shouldRenderForClientMixin = { | |
componentDidMount: function () { | |
this.setState({ | |
renderForClient: true | |
}) | |
}, | |
shouldRenderForClient: function () { | |
return typeof document !== 'undefined' && this.state && this.state.renderForClient; | |
} | |
}; | |
var Map = React.createClass({ | |
mixins: [shouldRenderForClientMixin], | |
render: function() { | |
if (!this.shouldRenderForClient()) { | |
return <img />; | |
} | |
return <FancyClientSideMap />; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@stratospark thanks for testing. you're right of course. I'll change it to: