Created
October 2, 2014 17:52
-
-
Save dmose/3804bfcd0e5213fa461e to your computer and use it in GitHub Desktop.
dependency injection example
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 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