Skip to content

Commit

Permalink
[@mantine/hooks] use-resize-observer: Fix types (#5847)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Mar 12, 2024
1 parent 7a4659a commit aad43b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/hooks/use-resize-observer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ See also [use-element-size](https://mantine.dev/hooks/use-element-size/) hook in
function useResizeObserver<T extends HTMLElement = any>(
options?: ResizeObserverOptions
): [
MutableRefObject<T>,
RefObject<T>,
{
x: number;
y: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const defaultState: ObserverRect = {

export function useResizeObserver<T extends HTMLElement = any>(options?: ResizeObserverOptions) {
const frameID = useRef(0);
const ref = useRef<T>();
const ref = useRef<T>(null);

const [rect, setRect] = useState<ObserverRect>(defaultState);

Expand Down Expand Up @@ -53,7 +53,7 @@ export function useResizeObserver<T extends HTMLElement = any>(options?: ResizeO
};
}, [ref.current]);

return [ref as any, rect] as const;
return [ref, rect] as const;
}

export function useElementSize<T extends HTMLElement = any>(options?: ResizeObserverOptions) {
Expand Down

0 comments on commit aad43b5

Please sign in to comment.