Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

ES6 - Syntax

0 votes
5 views
added Mar 8 in ES6 by LC Marshal Captain (20,510 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);

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...