I want to add inline style to an array of React Components, anyone know how best to do this without adding the height directly into the 'ProductComponent'?
The component has three nested divs I just want to add the style to the parent div for each component in the array. I want to do this in a ScrollableList component which takes an array of ProductComponents. I want to add "height:33%" on each ProductComponent.
My 'ProductComponent'.
class ProductComponent extends Component {
render() {
return (
<div
className="productContainer"
key={id}
>
<div className="imageContainer" >
<img src={ImageURL} role="presentation" />
</div>
<div className="productDetails">
<div className="productName"><strong>{Name}</strong></div>
<div className="productPrice">£ {Price}</div>
<div className="productBuyButton">
</div>
</div>
</div>
);
}
}
I have an array of these components I'm using as children in another ScrollableList component.
render(){
const array = this.props.children
const children = array.map(ProductComponent => {
return(
add style 'height:33%' to the div productContainer
}
return(
<div>
{children}
</div>
)
}