3 ms·
Amongst other things, the bind operator is very useful for React, so instead of having to call this.handleChange.bind(this) you can just call ::this.handlechang
by yladiz 10y ago
Amongst other things, the bind operator is very useful for React, so instead of having to call this.handleChange.bind(this) you can just call ::this.handlechange. As in, you can type this: <input onChange={::this.handleChange} />. It's a minor thing, but I prefer it a lot more than the explicit bind syntax. There are other cases as well, but since I'm doing a lot of work in React at the moment, having that is really convenient.
- marcusarmstrong 10y agoI've found using properties (which auto-bind) to be an easier solution.
- vsviridov 10y agoWith getters you can simply do { get handlerFn() { return (e) => ... } } And then in template <a onClick={this.handlerFn} />