diff --git a/src/useMeasure.ts b/src/useMeasure.ts index a5bee4aa4f..04e801d8ca 100644 --- a/src/useMeasure.ts +++ b/src/useMeasure.ts @@ -6,8 +6,8 @@ export type UseMeasureRect = Pick< DOMRectReadOnly, 'x' | 'y' | 'top' | 'left' | 'right' | 'bottom' | 'height' | 'width' >; -export type UseMeasureRef = (element: HTMLElement) => void; -export type UseMeasureResult = [UseMeasureRef, UseMeasureRect]; +export type UseMeasureRef = (element: E) => void; +export type UseMeasureResult = [UseMeasureRef, UseMeasureRect]; const defaultState: UseMeasureRect = { x: 0, @@ -20,8 +20,8 @@ const defaultState: UseMeasureRect = { right: 0, }; -const useMeasure = (): UseMeasureResult => { - const [element, ref] = useState(null); +const useMeasure = (): UseMeasureResult => { + const [element, ref] = useState(null); const [rect, setRect] = useState(defaultState); const observer = useMemo( @@ -46,6 +46,6 @@ const useMeasure = (): UseMeasureResult => { return [ref, rect]; }; -const useMeasureMock = () => [() => {}, defaultState]; +const useMeasureMock: typeof useMeasure = () => [() => {}, defaultState]; export default (isClient && !!(window as any).ResizeObserver) ? useMeasure : useMeasureMock;