I'm trying to create a component with React Native that includes a <Text> component inside the wrapped component:
const MyComponent = props => (
<View {...props}>
<Text {...props}>Hello world</Text>
<View>
)
const MyRedComponent = styled(MyComponent)`
color: #000;
margin-left: 10px;
background: #F00;
`
I'm composing my component this way so I could change the the text color from the same styled component as I'm changing the background color:
const MyBlueComponent = styled(MyRedComponent)`
color: #FFF;
background: #00F;
`
However with this approach there is a problem that all of the styles get applied to the <Text> component, not only the color; in this example the <Text> component also gets the margin-left style from the parent styles which is not preferred. I'd only like the text color to be cascaded to the <Text> component.
Is this possible using Styled Components with React Native?