I'm trying (unsuccessfully) to pass a single color value from a parent to a child using styled-components. If the color is passed correctly, the background should be the color that is passed. Else green. No matter what I do, the background-color is green What am I missing here?
The parent:
function App() {
return (
<div>
<Article color="red"/>
</div>
);
}
The child:
const MainContetnt = styled.div`
background-color: ${props => props.color ?? "green"};
flex: 1;
`;
const Article = (props) => {
return (
<MainContetnt>
Main content
</MainContetnt>
)
};