I have a problem with scss, I would like the color to be passed from parent (element_parent) to child (element_child) for even / odd parent numbers.
react code fragment:
<div>
{props.data && props.data.map(item => (
<div className="element_parent">
<ListElement
key={Math.floor(Math.random() * (100000000000 - 0)) + 0}
text={item.name}
/>
{item.value && <Tree data={item.value} generalVisible={item.generalVisible} visible={item.visible}/>}
</div>
))}
</div>
scss fragment code:
.element_parent:nth-child(even) .element_child {
background: #ccd9ff;
}
.element_parent:nth-child(odd) .element_child {
background: #ffffff;
}
In the ListElement component the element_child class is assigned.
question from:
https://stackoverflow.com/questions/65933890/react-passing-style-background-color-from-parent-to-child 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…