Skip to content

Commit

Permalink
fix: add more NaN type guards
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 5, 2020
1 parent 2402b5a commit 7664d1a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ export const BottomSheet = React.forwardRef<
maxHeightRef,
maxSnapRef,
minSnapRef,
updateSnap,
observeBoundsRef,
updateSnap,
} = useSnapResponder({
draggingRef,
maxHeight,
minSnap,
prefersReducedMotion,
maxSnap,
findSnap,
heightRef,
lastSnapRef,
maxHeight,
maxSnap,
minSnap,
prefersReducedMotion,
set,
})
useImperativeHandle(
Expand Down Expand Up @@ -485,6 +485,13 @@ export const BottomSheet = React.forwardRef<
axis: 'y',
})

if (Number.isNaN(maxSnapRef.current)) {
throw new TypeError('maxSnapRef is NaN!!')
}
if (Number.isNaN(minSnapRef.current)) {
throw new TypeError('minSnapRef is NaN!!')
}

// @TODO the ts-ignore comments are because the `extrapolate` param isn't in the TS defs for some reason
const interpolateBorderRadius =
maxHeightRef.current !== maxSnapRef.current
Expand Down

0 comments on commit 7664d1a

Please sign in to comment.