binding functions in react

A: hey, so why do we have to write "this.func = this.func.bind(this)" sometimes in React and sometimes not?

B: dunno. maybe it doesn't work if you try to use this.setState() in unbinded functions cause it doesn't know which "this" are you talking about

A: then why does it sometimes work???

B: ..... just bind it.

Answer

arrow functions bind this for you. ES5 functions do not.

ohsnap

oh