Closed erksch closed 2 years ago
@daxiangfei As described in the memoization section in README, the options have to be fixed on the first render. You probably can wrap the picker in a component that renders when the options are available.
btw, there is a simpler solution — just use the key
prop. like this f.e.:
const optionLabels = options.map(option => option.label);
return (
<WheelPicker
containerStyle={styles.picker}
decelerationRate="normal"
itemHeight={40}
itemTextStyle={styles.pickerItemText}
key={optionLabels.join('')}
options={optionLabels}
selectedIndex={selectedIndexes[index]}
selectedIndicatorStyle={styles.selectedIndicator}
visibleRest={2}
onChange={selected => handlePickerChange(index, selected)}
/>
When I use setState to set the options property, However, the old values(by options control) in the view are not updated.
Originally posted by @daxiangfei in https://github.com/erksch/react-native-wheely/issues/20#issuecomment-1091372488