<div id="root"></div>
class IncrementWidget extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      num: 0
    }
    //this.handleClick = this.handleClick.bind(this)
  }
  handleClick() {
    this.setState({
      num: this.state.num + 1
    })
  }
  render() {
    return (
      <div>
        <p>{this.state.num}</p>
        <button onClick={() => this.handleClick()}>Add</button>
      </div>
    )
  }
}

ReactDOM.render(<IncrementWidget />, document.getElementById('root'))
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js