Skip to content

Commit 8a612c2

Browse files
authored
fix(onChange): prevent extra render by preventing snapTo if index hasn't changed (#35)
1 parent c4e3552 commit 8a612c2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/BottomSheetView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ function BottomSheetModalScreen({
6565

6666
const onChange = React.useCallback(
6767
(newIndex: number) => {
68+
const currentIndex = lastIndexRef.current;
6869
lastIndexRef.current = newIndex;
69-
if (newIndex >= 0) {
70+
if (newIndex >= 0 && newIndex !== currentIndex) {
7071
navigation.snapTo(newIndex);
7172
}
7273
},

0 commit comments

Comments
 (0)