0
function Test(){  
const [height, setHeight] = useState(0);

  const myRef = useCallback(node => {
    if (node !== null) {
      setHeight(node.getBoundingClientRect().height);
    }
  }, []);
return(
<div ref = {myRef}>...</div>
)
}

This code does update the height on the first render/mount but when I change the window height, nothing happens. How can I make it update the height like I'd expect? I've also tried useEffect. This div is inside of another div and it is set to height : 100%.

Trunks159
  • 91
  • 9
  • 1
    You have many duplicates for this question, I tagged one of them, see solutions with https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver – Dennis Vash Dec 31 '22 at 19:13

0 Answers0