Using the State Hook – React

PHOTO EMBED

Fri Jan 07 2022 10:10:37 GMT+0000 (Coordinated Universal Time)

Saved by @fbturk

class Example extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
  }

  render() {
    return (
      <div>
        <p>You clicked {this.state.count} times</p>
        <button onClick={() => this.setState({ count: this.state.count + 1 })}>
          Click me
        </button>
      </div>
    );
  }
}
content_copyCOPY

https://reactjs.org/docs/hooks-state.html