1const NUM_OF_LINES = 5;
2const SOME_LONG_TEXT_BLOCK = 'Lorem ipsum ...';
3
4function SomeComponent () {
5 const [ showMore, setShowMore ] = useState(false);
6 const onTextLayout = useCallback(e => {
7 setShowMore(e.nativeEvent.lines.length > NUM_OF_LINES);
8 }, []);
9
10 return (
11 <Text numberOfLines={NUM_OF_LINES} onTextLayout={onTextLayout}>
12 {SOME_LONG_TEXT_BLOCK}
13 </Text>
14 );
15}
16