Answer the question
In order to leave comments, you need to log in
Correct use of JS function?
Good afternoon.
I have two examples of functions in a JSX block:
First:
<div onClick={() => this.onClick(35)}>
</div>
<div onClick={this.onClick.bind(this, 35)}>
</div>
Answer the question
In order to leave comments, you need to log in
Indeed, the code examples are equivalent (if you do not take into account that the number 35 should be the second argument to the bind function, you probably mistyped).
I will not undertake to talk about which method is better , but I myself use it more often and see arrow functions in someone else's code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question