how to calculate line height for text truncate?

Viewed 59

I'm using text truncate by height currently like this

const lineHeight = 90

that's the initial height for calculation with scroll height.

const calculateHeight = () => {
    const scrollHeight = para?.current.scrollHeight
    const isGreater = (lineHeight >= scrollHeight)
    setIsGreaterParaHeight(isGreater)
  }

and that's the calculation function

the issue is I want to do the calculation by props when someone passes line=1 so it will do the calculation for line 1 height how can I achieve that currently it's working for 3 lines by hardcoded 90 height

0 Answers
Related