I'm in the process of updating a React component to ES6 and suffered the problem described in this question - Unable to access React instance (this) inside event handler - namely not binding to the component instance.
That made sense and of course worked, but I'm confused about the other part of the answer:
Be aware that binding a function creates a new function. You can either bind it directly in render, which means a new function will be created every time the component renders, or bind it in your constructor, which will only fire once.
constructor() { this.changeContent = this.changeContent.bind(this); }
vs
render() { return <input onChange={this.changeContent.bind(this)} />; }
I'm assuming that binding in the constructor is the preferred approach for performance etc, but you know what they say about assume!
What are the trade-offs for these two approaches? Is there ever a situation where one is definitely better than the other? Or does it not matter?