I'm trying to pass an array of components to another components and render them after adding other props
import {ComponentB} from ".../ComponentB";
<ComponentA
list={[
<ComponentB title={'title 1'} />,
<ComponentB title={'title 2'} />,
<ComponentB title={'title 3'} />
]} />
How to loop over list props in ComponentA ?
this doesn't work :
// ComponentA
{ list.map((Item, index) => {
return (
<Item otherProps={'value xxx'}/>
)
})}
this yes but cannot add props
{ list.map((Item, index) => {
return (
{Item}
)
})}
// ComponentA, you have donevar list = this.props.list? Otherwise, thatlistvar is undefined.