Answers for "add number of lines to text react native"

1

text number of lines react native

<Text numberOfLines={2} ellipsizeMode='tail'>
  long string
</Text>
Posted by: Guest on February-10-2021
1

react native text get number of lines

const NUM_OF_LINES = 5;
const SOME_LONG_TEXT_BLOCK = 'Lorem ipsum ...';

function SomeComponent () { 
  const [ showMore, setShowMore ] = useState(false);
  const onTextLayout = useCallback(e => {
    setShowMore(e.nativeEvent.lines.length > NUM_OF_LINES);
  }, []);

  return (
    <Text numberOfLines={NUM_OF_LINES} onTextLayout={onTextLayout}>
      {SOME_LONG_TEXT_BLOCK}
    </Text>
  );
}
Posted by: Guest on September-15-2021

Code answers related to "add number of lines to text react native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language