← React Beginner Questions - Set 11 Q107

How do you bind event handlers in React?

React Beginner Questions - Set 11

Example

// Function component: no binding needed
<button onClick={this.handleClick}>  // class: bind in constructor or use an arrow field
handleClick = () => this.setState({ open: true });

What to notice

← Back to the question list