'Get real height of element react
My div is not visible on the screen and obviously the height is 0px. However, the clientHeight returns 154. What is my mistake? I would want to get the real height of the div that I see on the screen.
function TestComponent() {
const iframeRef = React.useRef<HTMLDivElement>(null);
useEffect(() => {
console.log('HEIGHT HERE: ',iframeRef.current?.getBoundingClientRect().height); // return 154
}, [iframeRef.current]);
return <div className='test'>...</div>
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

