Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <script src="//fb.me/react-with-addons-0.13.1.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="container"></div>
</body>
</html>
 
/** @jsx React.DOM */
var Panel = React.createClass({
  getInitialState: function(){
    return {
      count: 0
    }
  },
  
  tick: function() {
    setInterval(function(that) {
      that.setState({
        count: that.state.count + 1
      });
    }, 500, this);
  },
  
  componentDidMount: function() {
    var panel = React.findDOMNode(this.refs.panel);
    React.render(<Counter count={this.state.count}/>, panel);
    this.tick();
  },
  
  render: function(){
    return <div ref="panel"></div>;
  }
});
var Counter = React.createClass({
  render: function() {
    return <p>{this.props.count}</p>
  }
});
React.render(<Panel/>, document.getElementById('container'));
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers