Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//fb.me/react-0.14.3.js"></script>
<script src="//fb.me/react-dom-0.14.3.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <div id="app"></div>
</body>
</html>
 
class App extends React.Component {
  constructor(props) {
    super(props);
    
    this.state = {
      clicks: 0
    };
    
    this.click = this.click.bind(this);
    this.manyClicks = this.manyClicks.bind(this);
  }
  
  click() {
    this.setState({clicks: this.state.clicks + 1});
  }
  
  manyClicks() {
    var i = 0;
    for (i = 0; i < 100; i++) {
      this.click();
    }
  }
  
  render() {
    return (
      <div>
        <button onClick={this.click}>1 Click</button>
        <button onClick={this.manyClicks}>100 Clicks</button>
        <h3>{this.state.clicks}</h3>
      </div>
    );
  }
}
ReactDOM.render(<App />, document.getElementById('app'));
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers