You can use the arrow function in combination with property initialization.
class Component extends React.Component { handleClick = () => { console.log(this.props); } render() { return <div onClick={this.handleClick} /> } }
Since the arrow function is declared in the constructor area, but because the arrow functions support this from their declaration area, it all works. The disadvantage here is that they will not be functions on the prototype, they will all be recreated with each component. However, this is not so much, since bind does the same.
source share