I have a component which will show a list of items with two Text
next to each other. one for the title and one for the content. here is my render implementation:
let items = [
{title: 'Test Test:', value: 'Long Test Long Test Long Test Long Test Long Test Long Test Long Test'},
{title: 'Test:', value: 'Short Test Test Test'},
];
return (<FlatList
style={{flex: 1, width: Dimensions.get('window').width}}
data={items}
renderItem={({item}) =>
<View style={{flexDirection: 'row', width: Dimensions.get('window').width}}>
<Text style={{color: colors.accentColor}}>{item.title}</Text>
<Text>{item.value}</Text>
</View>
}/>);
the problem is text is not wrapped and it's getting of the screen when it's a long text. How can I fix it?
I reproduced your case and I manage to do the correct wrapping by putting a flex: 1
property on your Long text :
<View style={{flexDirection: 'row', width: Dimensions.get('window').width}}>
<Text style={{color: "red"}}>{item.title}</Text>
<Text style={{flex: 1}}>{item.value}</Text>
</View>
Tell me if it works for you !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With