The more I learn JS the more I am worried that I am not using 'this' right.
I swap back and forth between javascript/python and with JS it always feels like I am one step away from disaster if I accidentally forget to bind this.
I swap back and forth between javascript/python and with JS it always feels like I am one step away from disaster if I accidentally forget to bind this.
I've been preferring just setting up the bindings in the constructor over arrow functions.
So for the author's example I'd just do: constructor (){ this.increment.bind(this); }
Then the template can stay cleaner with just onClick={this.increment}
var that = this
just to be sure