I have a loop that displays data and when clicking the data it should run a method that gets the clicked item.
ie:
items.map(item => {
return (
<div
onClick={someMethod(item)}>
Some content
</div>
);
}
The example won’t work properly but it’s just to show the situation. I know 2 options but both will make the template render each time:
Use arrow function
onClick={()=>someMethod(item)}
Use bind
onClick={someMethod.bind(this, item)}
Any better ideas that won’t cause rerender?