Skip to content

Instantly share code, notes, and snippets.

@dmose
Created October 2, 2014 17:52
Show Gist options
  • Save dmose/3804bfcd0e5213fa461e to your computer and use it in GitHub Desktop.
Save dmose/3804bfcd0e5213fa461e to your computer and use it in GitHub Desktop.
dependency injection example
var EmptyRoomView = React.createClass({
propTypes: {
// store: React.PropTypes.instanceOf(loop.store.RoomStore).isRequired,
roomName: React.PropTypes.string.isRequired,
document: React.PropTypes.object // used for testing
},
getInitialState: function() {
return {};
},
componentWillMount: function() {
if (this.props.hasOwnProperty("document")) {
this.setState({document: this.props.document});
} else {
this.setState({document: window.document});
}
},
render: function() {
this.state.document.title = this.props.roomName;
return null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment