I have following code where I need to pass index value to the event handler which I am getting as a prop from another component. How can I achieve this without using the inline syntax, as inline syntax is not considered as a good approach since it may lead to the creation of new function each time the component re-renders?
const Persons = (props) => {
return (props.persons.map((person, index) => {
return <Person
click={() => props.click(index)}
name={person.name}
age={person.age}
key={person.id}
changed={(event) => props.changed(event, person.id)} />
}));
}