📌  相关文章
📜  文本行数反应本机 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:21.261000             🧑  作者: Mango

代码示例2
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 (
    
      {SOME_LONG_TEXT_BLOCK}
    
  );
}