fix: Cannot read properties of undefined (reading 'width')

This commit is contained in:
Tom Moor
2023-10-07 20:59:18 -04:00
parent b6706efe6f
commit 2f3247b500

View File

@@ -28,11 +28,12 @@ export default function useComponentSize(
useEffect(() => {
const handleResize = () => {
setSize((state: DOMRect) => {
setSize((state) => {
const rect = element?.getBoundingClientRect();
if (
rect &&
state &&
Math.round(state.width) === Math.round(rect.width) &&
Math.round(state.height) === Math.round(rect.height) &&
Math.round(state.x) === Math.round(rect.x) &&