ES6 - Syntax

0 votes
added Mar 8, 2019 in ES6 by LC Marshal Captain (25,790 points)

Extra careful with the meaning of this in JSX callbacks. In JavaScript, class methods aren't bound by default. It'll throw undefined  if you forget to bind this.handleClick.

// This binding (.bind) is a must to make `this` work in the callback
this.handleClick = this.handleClick.bind(this); - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.