Answers for "get height component react"

-1

get height component react

import React, { useState, useEffect, useRef } from 'react'

export default () => {
  const [height, setHeight] = useState(0)
  const ref = useRef(null)

  useEffect(() => {
    setHeight(ref.current.clientHeight)
  })

  return (
    <div ref={ref}>
      {height}
    </div>
  )
}
Posted by: Guest on September-19-2021

Code answers related to "get height component react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language