SOLVED (solution at the end)
I have the following layout, I want the text SOME LOOOOOOOOOOOOOONG TEXT
to don´t break the line and show an ellipse.
E.x.: Pangaré Figueiredo SOME LOOOOOO...
const LastHighline = (props: Props) => {
return (
<TouchableOpacity className="my-3 flex-row items-center gap-x-3">
<View className="flex-initial">
<HistorySvg />
</View>
<Text className="flex-1 overflow-hidden whitespace-nowrap overflow-ellipsis">{props.name} SOME LOOOOOOOOOOOOOONG TEXT</Text>
<View className="flex-shrink-0 flex-row items-center">
<HeightSvg />
<Text>{props.height}m</Text>
</View>
<View className="flex-shrink-0 flex-row items-center gap-x-2">
<WidthSvg />
<Text>{props.length}m</Text>
</View>
</TouchableOpacity>
);
};
Solution
Just put flex-1
in order to make the element shrink and grow when necessary, and the truncate
was substituted with a property of <Text>
tag named numberOfLines
, set to 1 and got the expected result
check the resource here How to have Ellipsis effect on Text
<Text className="flex-1" numberOfLines={1}>{props.name} SOME LOOOOOOOOOOOOOONG TEXT</Text>`