Skip to content

Commit f079360

Browse files
committed
fix: measureInWindow on web platform
1 parent a2186ba commit f079360

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Shimmer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type ViewStyle,
66
Dimensions,
77
type LayoutChangeEvent,
8+
Platform,
89
} from 'react-native';
910
import Animated, {
1011
Easing,
@@ -51,7 +52,11 @@ export const Shimmer = ({
5152
const measure = useCallback(
5253
(event: LayoutChangeEvent) => {
5354
if (componentWidth === 0) {
54-
event.target.measureInWindow((x, _y, width) => {
55+
const measureInWindowFn =
56+
Platform.OS === 'web'
57+
? event.nativeEvent.target.measureInWindow
58+
: event.target.measureInWindow;
59+
measureInWindowFn((x, _y, width) => {
5560
setComponentWidth(width);
5661
setOffset(x);
5762
});

0 commit comments

Comments
 (0)