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%.