An example will explain better then I can ever formulate it
In below code, how to pass the index to Child when Child is passed in as a prop
const ComponentA = (props) => {
return (
<div>
{ data.map((item,index) => {
return (
<Child index={index} />
);
})
}
</div>
)
}
So my component A would look like this, and I want to pass the index to (each of) the children
const ComponentA = (props) => {
return (
<div>
{ data.map((item,index) => {
return (
{props.children}
);
})
}
</div>
)
}
thanks