Skip to content

Commit

Permalink
Set options to observed element in useResizeObserver #162
Browse files Browse the repository at this point in the history
  • Loading branch information
leroykorterink committed Dec 4, 2023
1 parent c705fdf commit 272ad30
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hooks/useResizeObserver/useResizeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { unref, type Unreffable } from '../../utils/unref/unref.js';
export function useResizeObserver(
target: Unreffable<Element | null>,
callback?: ResizeObserverCallback | undefined,
options?: ResizeObserverOptions,
): void {
useEffect(() => {
const element = unref(target);
Expand All @@ -20,10 +21,10 @@ export function useResizeObserver(
}

const resizeObserver = new ResizeObserver(callback);
resizeObserver.observe(element);
resizeObserver.observe(element, options);

return () => {
resizeObserver.disconnect();
};
}, [target, callback]);
}, [target, callback, options]);
}

0 comments on commit 272ad30

Please sign in to comment.