Skip to content

Commit 7f5563c

Browse files
committed
main 🧊 fix ref
1 parent 665d585 commit 7f5563c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/hooks/useMeasure/useMeasure.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { RefObject } from 'react';
22

3-
import { useRef, useState } from 'react';
3+
import { useState } from 'react';
44

5+
import { useRefState } from '../useRefState/useRefState';
56
import { useResizeObserver } from '../useResizeObserver/useResizeObserver';
67

78
/** The use measure target element type */
@@ -40,7 +41,7 @@ export interface UseMeasureScreen {
4041
* const { ref, x, y, width, height, top, left, bottom, right } = useMeasure();
4142
*/
4243
export const useMeasure = (<Target extends UseMeasureTarget>(target?: Target) => {
43-
const internalRef = useRef<Element>();
44+
const internalRef = useRefState<Element>();
4445
const [rect, setRect] = useState({
4546
x: 0,
4647
y: 0,
@@ -52,7 +53,7 @@ export const useMeasure = (<Target extends UseMeasureTarget>(target?: Target) =>
5253
right: 0
5354
});
5455

55-
useResizeObserver(target ?? internalRef, {
56+
useResizeObserver((target ?? internalRef.current) as Element, {
5657
onChange: ([entry]) => {
5758
if (!entry) return;
5859

0 commit comments

Comments
 (0)