Reputation: 21
I am using Styled Components with my React Native app and I am trying to figure out how to use multiple props.
My Component :
<SelectedPill active={true} color={'red'}>Text Here</SelectedPill>
My Styled Component :
const SelectedPill = styled.TouchableOpacity`
${({active}) => active && `
background: ${props => (props.color ? props.color : '#292929')};
`};
`
What I'm trying to do in the styled component is that if the prop "active" is set to true, then get the "color" props int he components and apply it.
Upvotes: 0
Views: 364
Reputation: 6257
This should work:
const SelectedPill = styled.TouchableOpacity`
${({active, color}) => active && `
background: ${color ? color : 'red'};
`};
`
Upvotes: 0