as far as I know we cannot use this
keyword in arrow functions. However, in react I have seen that this is possible. I was wondering how this is possible.
Example:
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
}
render() {
return (
<div>
<p>You clicked {this.state.count} times</p>
<button onClick={() => this.setState({ count: this.state.count + 1 })}>
Click me
</button>
</div>
);
}
}
https://reactjs.org/docs/hooks-state.html