I have a TouchableOpacity
with a Text
component inside it in my React Native app, and I want the TouchableOpacity
to be only as wide as the Text
. I've tried doing this:
<TouchableOpacity style={{flexDirection: 'row', flexBasis: 0, flexShrink: 1}}>
<Text>text</Text>
</TouchableOpacity>
But the TouchableOpacity
is still as wide as the whole screen. flexGrow
is 0 by default, so I figured by allowing the TouchableOpacity
to shrink with flexShrink
and having its flexBasis
be zero,