📌  相关文章
📜  反应原生文本获取行数 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:07.788000             🧑  作者: 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}
    
  );
}