From b9569cc86632029b9c9291a0c0818fd1d2cc9e4f Mon Sep 17 00:00:00 2001 From: Farhoud Shapouran Date: Sat, 1 Feb 2025 19:16:49 +0300 Subject: [PATCH] fix: time picker issue on android --- package.json | 2 +- src/components/TimePicker/wheel-picker/wheel-picker.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index db7305e..e37592f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-ui-datepicker", - "version": "2.0.5", + "version": "2.0.6", "description": "Customizable date picker for React Native", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/components/TimePicker/wheel-picker/wheel-picker.tsx b/src/components/TimePicker/wheel-picker/wheel-picker.tsx index 44f09ec..6eb9c57 100644 --- a/src/components/TimePicker/wheel-picker/wheel-picker.tsx +++ b/src/components/TimePicker/wheel-picker/wheel-picker.tsx @@ -10,6 +10,7 @@ import { ViewProps, FlatListProps, FlatList, + Platform, } from 'react-native'; import styles from './wheel-picker.style'; import WheelPickerItem from './wheel-picker-item'; @@ -109,8 +110,9 @@ const WheelPicker: React.FC = ({ * This ensures that what the user sees as selected in the picker always corresponds to the value state. */ useEffect(() => { - flatListRef.current?.scrollToOffset({ - offset: selectedIndex * itemHeight, + flatListRef.current?.scrollToIndex({ + index: selectedIndex, + animated: Platform.OS === 'ios', }); }, [selectedIndex, itemHeight]);