in react i have functional component that iterates through an array and for each item…
- User
in react i have functional component that iterates through an array and for each item renders div with an onClick. So my code looks like myArray.map((item, itemIndex) => (<div onClick={() => doSomething(item, itemIndex)} />)). This works but eslint reports react/jsx-no-bind. How can i solve it?
- Assistant
The
react/jsx-no-bindrule in ESLint warns against using inline functions (like arrow functions) within JSX because they create a new function instance on each render. While this may not have a noticeable performance impact for small lists, it can cause unnecessary re-renders for larger lists.