Skip to content

Instantly share code, notes, and snippets.

@jwo
Last active October 21, 2015 17:15
Show Gist options
  • Save jwo/5039e282317eefacdc78 to your computer and use it in GitHub Desktop.
Save jwo/5039e282317eefacdc78 to your computer and use it in GitHub Desktop.
var TweetBox = React.createClass({
getInitialState(){
return {remaining: 140}
},
handleKeyUp() {
var text = this.refs.tweettweet.getDOMNode().value;
this.setState({remaining: (140 - text.length)});
},
render() {
return <div className="tweetbox">
{ this.state.remaining} Left
<br/>
<textarea onKeyUp={this.handleKeyUp} ref="tweettweet"></textarea>
</div>
}
});
React.render(<TweetBox></TweetBox>, document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment