Skip to content

Fix/ wheelPicker - uncontrolled mode #1583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ const SectionsWheelPickerScreen = () => {
{
items: getItems(days),
onChange: onDaysChange,
selectedValue: selectedDays,
initialValue: selectedDays,
label: 'Days',
align: numOfSections === 1 ? WheelPicker.alignments.CENTER : WheelPicker.alignments.RIGHT,
style: {flex: 1}
},
{
items: getItems(hours),
onChange: onHoursChange,
selectedValue: selectedHours,
initialValue: selectedHours,
label: 'Hrs',
align: numOfSections === 2 ? WheelPicker.alignments.LEFT : WheelPicker.alignments.CENTER,
style: numOfSections === 2 ? {flex: 1} : undefined
},
{
items: getItems(minutes),
onChange: onMinutesChange,
selectedValue: selectedMinutes,
initialValue: selectedMinutes,
label: 'Mins',
align: WheelPicker.alignments.LEFT,
style: {flex: 1}
Expand Down
4 changes: 2 additions & 2 deletions src/incubator/WheelPicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO: Support style customization
import {isFunction} from 'lodash';
import {isFunction, isUndefined} from 'lodash';
import React, {useCallback, useRef, useMemo, useEffect, useState} from 'react';
import {TextStyle, ViewStyle, FlatList, NativeSyntheticEvent, NativeScrollEvent, StyleSheet} from 'react-native';
import Animated, {useSharedValue, useAnimatedScrollHandler} from 'react-native-reanimated';
Expand Down Expand Up @@ -139,7 +139,7 @@ const WheelPicker = ({

/* This effect making sure to reset index if initialValue has changed */
useEffect(() => {
scrollToIndex(currentIndex, true);
!isUndefined(initialValue) && scrollToIndex(currentIndex, true);
}, [currentIndex]);

const scrollToPassedIndex = useCallback(() => {
Expand Down