@trackunit/react-components 0.4.21 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +4 -3
- package/index.esm.js +4 -3
- package/package.json +1 -1
- package/src/hooks/useGeometry.d.ts +2 -1
package/index.cjs.js
CHANGED
|
@@ -1162,8 +1162,9 @@ const useGeometry = (ref) => {
|
|
|
1162
1162
|
y: 0,
|
|
1163
1163
|
});
|
|
1164
1164
|
const resizeObserver = React.useRef(null);
|
|
1165
|
+
const refCurrent = ref.current;
|
|
1165
1166
|
React.useEffect(() => {
|
|
1166
|
-
if (!
|
|
1167
|
+
if (!refCurrent) {
|
|
1167
1168
|
return;
|
|
1168
1169
|
}
|
|
1169
1170
|
if (!resizeObserver.current) {
|
|
@@ -1183,13 +1184,13 @@ const useGeometry = (ref) => {
|
|
|
1183
1184
|
}
|
|
1184
1185
|
});
|
|
1185
1186
|
}
|
|
1186
|
-
resizeObserver.current.observe(
|
|
1187
|
+
resizeObserver.current.observe(refCurrent);
|
|
1187
1188
|
return () => {
|
|
1188
1189
|
if (resizeObserver.current) {
|
|
1189
1190
|
resizeObserver.current.disconnect();
|
|
1190
1191
|
}
|
|
1191
1192
|
};
|
|
1192
|
-
}, [
|
|
1193
|
+
}, [refCurrent]);
|
|
1193
1194
|
return geometry;
|
|
1194
1195
|
};
|
|
1195
1196
|
|
package/index.esm.js
CHANGED
|
@@ -1142,8 +1142,9 @@ const useGeometry = (ref) => {
|
|
|
1142
1142
|
y: 0,
|
|
1143
1143
|
});
|
|
1144
1144
|
const resizeObserver = useRef(null);
|
|
1145
|
+
const refCurrent = ref.current;
|
|
1145
1146
|
useEffect(() => {
|
|
1146
|
-
if (!
|
|
1147
|
+
if (!refCurrent) {
|
|
1147
1148
|
return;
|
|
1148
1149
|
}
|
|
1149
1150
|
if (!resizeObserver.current) {
|
|
@@ -1163,13 +1164,13 @@ const useGeometry = (ref) => {
|
|
|
1163
1164
|
}
|
|
1164
1165
|
});
|
|
1165
1166
|
}
|
|
1166
|
-
resizeObserver.current.observe(
|
|
1167
|
+
resizeObserver.current.observe(refCurrent);
|
|
1167
1168
|
return () => {
|
|
1168
1169
|
if (resizeObserver.current) {
|
|
1169
1170
|
resizeObserver.current.disconnect();
|
|
1170
1171
|
}
|
|
1171
1172
|
};
|
|
1172
|
-
}, [
|
|
1173
|
+
}, [refCurrent]);
|
|
1173
1174
|
return geometry;
|
|
1174
1175
|
};
|
|
1175
1176
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Custom hook to get the geometry of an element.
|
|
3
4
|
* Size and position of the element relative to the viewport.
|
|
4
5
|
*/
|
|
5
|
-
export declare const useGeometry: (ref:
|
|
6
|
+
export declare const useGeometry: (ref: RefObject<HTMLElement>) => {
|
|
6
7
|
width: number;
|
|
7
8
|
height: number;
|
|
8
9
|
top: number;
|