diff --git a/src/hooks/useResizeObserver/useResizeObserver.ts b/src/hooks/useResizeObserver/useResizeObserver.ts index c95193d741..3c247768c4 100644 --- a/src/hooks/useResizeObserver/useResizeObserver.ts +++ b/src/hooks/useResizeObserver/useResizeObserver.ts @@ -3,9 +3,14 @@ import React from 'react'; interface UseResizeObserverProps { ref: React.RefObject | undefined; onResize: () => void; + box?: ResizeObserverBoxOptions; } -export function useResizeObserver({ref, onResize}: UseResizeObserverProps) { +export function useResizeObserver({ + ref, + onResize, + box, +}: UseResizeObserverProps) { React.useEffect(() => { const element = ref?.current; if (!element) { @@ -26,9 +31,9 @@ export function useResizeObserver({ref, onResize}: UseResizeO onResize(); }); - observer.observe(element); + observer.observe(element, {box}); return () => { observer.disconnect(); }; - }, [ref, onResize]); + }, [ref, onResize, box]); }