[React] Onclick function
onClick function is useful(personally) and common method. it executes some event when mouse button is clicked. To do that, There are 3 steps
- declare onClick e.g <h2 onClick={this.handleClick}>Just some info</h2>
- create event function. handleClick() { this.setState({cars: this.state.cars.reverse()}); }
- bind it e.g this.handleClick = this.handleClick.bind(this);