diff --git a/packages/desktop-client/src/hooks/useResizeObserver.ts b/packages/desktop-client/src/hooks/useResizeObserver.ts index 4137dd92524..58573eff5d5 100644 --- a/packages/desktop-client/src/hooks/useResizeObserver.ts +++ b/packages/desktop-client/src/hooks/useResizeObserver.ts @@ -1,20 +1,19 @@ -// @ts-strict-ignore import { useRef, useCallback } from 'react'; -export function useResizeObserver( +export function useResizeObserver( func: (contentRect: DOMRectReadOnly) => void, -): (el: unknown) => void { - const observer = useRef(null); +): (el: T) => void { + const observer = useRef(undefined); if (!observer.current) { observer.current = new ResizeObserver(entries => { func(entries[0].contentRect); }); } - const elementRef = useCallback(el => { - observer.current.disconnect(); + const elementRef = useCallback((el: T) => { + observer.current?.disconnect(); if (el) { - observer.current.observe(el, { box: 'border-box' }); + observer.current?.observe(el, { box: 'border-box' }); } }, []);