File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/incubator/WheelPicker Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -122,10 +122,8 @@ const WheelPicker = React.memo(({
122
122
} ;
123
123
124
124
const scrollToIndex = ( index : number , animated : boolean ) => {
125
- if ( scrollView . current ?. getNode ( ) ) {
126
- //@ts -ignore for some reason scrollToOffset isn't recognized
127
- scrollView . current ?. getNode ( ) ?. scrollToOffset ( { offset : index * itemHeight , animated} ) ;
128
- }
125
+ //@ts -ignore for some reason scrollToOffset isn't recognized
126
+ scrollView . current ?. scrollToOffset ( { offset : index * itemHeight , animated} ) ;
129
127
} ;
130
128
131
129
const selectItem = useCallback ( index => {
@@ -181,6 +179,10 @@ const WheelPicker = React.memo(({
181
179
} ,
182
180
[ ] ) ;
183
181
182
+ const getItemLayout = useCallback ( ( _data , index : number ) => {
183
+ return { length : itemHeight , offset : itemHeight * index , index} ;
184
+ } , [ itemHeight ] ) ;
185
+
184
186
const contentContainerStyle = useMemo ( ( ) => {
185
187
return { paddingVertical : height / 2 - itemHeight / 2 } ;
186
188
} , [ height , itemHeight ] ) ;
@@ -205,6 +207,8 @@ const WheelPicker = React.memo(({
205
207
snapToInterval = { itemHeight }
206
208
decelerationRate = { Constants . isAndroid ? 0.98 : 'normal' }
207
209
renderItem = { renderItem }
210
+ getItemLayout = { getItemLayout }
211
+ initialScrollIndex = { currentIndex }
208
212
/>
209
213
</ View >
210
214
{ label && renderLabel ( ) }
You can’t perform that action at this time.
0 commit comments