The PostList function is a component inside FlatList.
When I have an item.Image, I want the Image to occupy that size with conditional rendering and push item.content
But with my code, it doesn't take up as wide as the Image due to item.content. like this Screenshot the green one is Image width
How can I push the item.content when the item.Image is present while the Image takes up its normal width?
this is my code
const PostList = ({item}: Props) => {
return (
<>
<View style={styles.main}>
<View style={styles.min}>
<View style={styles.middlecon}>
<Text style={styles.content} numberOfLines={2} ellipsizeMode="tail">
{item.content}
</Text>
</View>
</View>
{item.Image && (
<View style={styles.rightcon}>
<Image style={styles.Image} />
</View>
)}
</View>
</>
);
};
const styles = StyleSheet.create({
main: {
borderBottomWidth: 0.3,
borderColor: '#b0b4b8',
paddingBottom: 30,
flexDirection: 'row',
justifyContent: 'space-between',
},
min: {},
middlecon: {},
content: {},
rightcon: {
backgroundColor: 'lightblue',
},
Image: {
width: 100,
height: 30,
backgroundColor: 'lightgreen',
},
});
