Skip to content

Commit 7664d1a

Browse files
committed
fix: add more NaN type guards
1 parent 2402b5a commit 7664d1a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/BottomSheet.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ export const BottomSheet = React.forwardRef<
142142
maxHeightRef,
143143
maxSnapRef,
144144
minSnapRef,
145-
updateSnap,
146145
observeBoundsRef,
146+
updateSnap,
147147
} = useSnapResponder({
148148
draggingRef,
149-
maxHeight,
150-
minSnap,
151-
prefersReducedMotion,
152-
maxSnap,
153149
findSnap,
154150
heightRef,
155151
lastSnapRef,
152+
maxHeight,
153+
maxSnap,
154+
minSnap,
155+
prefersReducedMotion,
156156
set,
157157
})
158158
useImperativeHandle(
@@ -485,6 +485,13 @@ export const BottomSheet = React.forwardRef<
485485
axis: 'y',
486486
})
487487

488+
if (Number.isNaN(maxSnapRef.current)) {
489+
throw new TypeError('maxSnapRef is NaN!!')
490+
}
491+
if (Number.isNaN(minSnapRef.current)) {
492+
throw new TypeError('minSnapRef is NaN!!')
493+
}
494+
488495
// @TODO the ts-ignore comments are because the `extrapolate` param isn't in the TS defs for some reason
489496
const interpolateBorderRadius =
490497
maxHeightRef.current !== maxSnapRef.current

0 commit comments

Comments
 (0)