Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
How to check that my data has been passed to the variable before it is rendered?(useRef)

I have this button that appears only when its text overflows its parent container. So far it works but when I go to refresh the page I get a typeerror of "Cannot read properties of undefined (reading 'clientHeight')."

I believe this is because my variable el hasn't finished pulling my data from my useRef. How can I check that my variable has passed in my data successfully before being rendered?

const inputRef = useRef<HTMLDivElement>()
const checkOverflowing = () => {
        const el = inputRef.current
        const isOverflowing = el.clientHeight < el.scrollHeight
        return isOverflowing
    }

return (
<div ref={inputRef} className="comment-for-user">{review.comments}</div>

            <div className="show-more-360">
                {checkOverflowing() &&
                    <button className="show-more-button" onClick={handleEvent}>...show More</button>}
            </div>)
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!