Skip to content

Commit 0715f03

Browse files
committed
fix(#2267): early exit when attempting to snap to index while layout is not ready
1 parent e17096f commit 0715f03

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,14 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
960960
index: number,
961961
animationConfigs?: WithSpringConfig | WithTimingConfig
962962
) {
963-
const snapPoints = animatedSnapPoints.value;
963+
const snapPoints = animatedSnapPoints.get();
964+
const isLayoutReady = isLayoutCalculated.get();
965+
966+
// early exit if layout is not ready yet.
967+
if (!isLayoutReady) {
968+
return;
969+
}
970+
964971
invariant(
965972
index >= -1 && index <= snapPoints.length - 1,
966973
`'index' was provided but out of the provided snap points range! expected value to be between -1, ${

src/hooks/usePropsValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export const usePropsValidator = ({
2121
useMemo(() => {
2222
//#region snap points
2323
const _snapPoints = snapPoints
24-
? 'value' in snapPoints
25-
? snapPoints.value
24+
? 'get' in snapPoints
25+
? snapPoints.get()
2626
: snapPoints
2727
: [];
2828
invariant(

0 commit comments

Comments
 (0)