Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <script src="https://fb.me/react-with-addons-0.14.7.min.js"></script>
  <script src="https://fb.me/react-dom-0.14.7.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <h2>Events and methods</h2>
  <div id="app">
    
  </div>
</body>
</html>
 
class Counter extends React.Component {
  constructor(){
    super();
    this.state = {
      count: 0
    };
  }
  handleClickMe(e) { //Oops what's wrong? :O
    let newCount = this.state.count + 1;
    this.setState({
      count: newCount
    });
  }
  render() {
    return (
      <div>Count: {this.state.count}
        <br/>
        <button onClick={this.handleClickMe}>Increase me</button>
      </div>
    );
  }
}
let appEl = document.getElementById('app');
ReactDOM.render(<Counter />, appEl);
Output 300px

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

Dismiss x
public
Bin info
rkotzepro
0viewers