Created
July 4, 2015 03:42
-
-
Save xiujunma/cf0c0c47d5022630b9bf to your computer and use it in GitHub Desktop.
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
var Page = React.createClass({ | |
getInitialState: function() { | |
return {word: null}; | |
}, | |
componentDidMount: function() { | |
var ws = new WebSocket("ws://url.com/ws"); | |
var self = this; | |
ws.onmessage = function(msg) { | |
self.setState({word: msg}); | |
} | |
}, | |
render: function() { | |
return (<span>{this.state.word}</span>) | |
} | |
}); | |
React.render(<Page />, | |
document.body | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment