<div id="root"></div>
class Counter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 0
    };
  }

  increment() {
    this.setState((prevState) => ({
      value: prevState.value + 1
    }));
  }

  render() {
    return (
      <>
        <p>Value: {this.state.value}</p>
        <button onClick={() => this.increment()}>+1</button>
      </>
    );
  }
}

ReactDOM.render(<Counter />, 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/17.0.1/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js