Skip to content

Instantly share code, notes, and snippets.

@alx8437
Created November 24, 2021 18:20
Show Gist options
  • Save alx8437/61ed49aeb474b4b5695505601618f063 to your computer and use it in GitHub Desktop.
Save alx8437/61ed49aeb474b4b5695505601618f063 to your computer and use it in GitHub Desktop.
const [containerHeight, setContainerHeight] = useState<number>(0);
const containerHeightRef = useCallback((node) => {
if (node !== null) {
setContainerHeight(node.getBoundingClientRect().height);
}
}, []);
<div ref={containerHeightRef}></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment