Answer the question
In order to leave comments, you need to log in
Iterating and passing elements through an attribute to a component?
It is necessary to iterate over the array returning the values in jsx format and then passing them to the attribute of the component. Working example:
<ul>
{this.props.productsInBasket.map((product) => <li key={product.name}>{product.name}</li>)}
</ul>
wrappers.map(function(el){
return <Wrapper element={el} childern={el.require.map((child) => <li>{child.name}</li>)}/>
})
Answer the question
In order to leave comments, you need to log in
wrappers.map(function(el){
return (
<Wrapper element={el}>
{el.require.map((child, key) => {
return <li key={key}>{child.name}</li>
})}
<Wrapper/>
);
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question