What is a good way to automatically bind JS class methods?

Use fat arrow function in ES6 (generally called as arrow function)

anotherOne = ()=> {
...
}

Call like this onClick={this.anotherOne}; no need to bind in constuctor

From the ECMA spec

Any reference to arguments, super, this, or new.target within an
ArrowFunction must resolve to a binding in a lexically enclosing
environment. Typically this will be the Function Environment of an
immediately enclosing function.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)