I would like to know if there is a performance difference between using bind
and an anonymous function in React components.
Concretely, is one of the following more performant than another?
const MyComponent = ({ myHandler }) => {
...
return (
<a onClick={myHandler.bind(this, foo, bar)} ...>
hello world
</a>
);
}
const MyComponent = ({ myHandler }) => {
...
return (
<a
onClick={() => {
myHandler(this, foo, bar)
}
...
>
hello world
</a>
);
}
This question is different from the possible duplicate because the answer to the possible duplicate question focuses on the memory footprint.