lawnstarter / react-native-picker-select

🔽 A Picker component for React Native which emulates the native <select> interfaces for iOS and Android
https://npmjs.com/package/react-native-picker-select
MIT License
1.76k stars 499 forks source link

Scrolling when I have duplicate value in items #386

Closed wenit123 closed 4 years ago

wenit123 commented 4 years ago

Describe the bug
I have duplicate value in the items array. When I select the one I want, it show the selected one in the screen. But in drop down will scroll automatically to the last one of the same value.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'screen'
  2. Click on 'drop down'
  3. Scroll down to ' Wyoming 0%'
  4. See error, the value show on the screen is right, but in dropdown it jump to 'Montana 0%'

Expected behavior

Screenshots
image

Screen Shot 2020-11-02 at 12 18 42 PM

Additional details

Reproduction and/or code sample


                  placeholder={{
                    label: 'Select tax rate...',
                    value: 0,
                  }}
                  onValueChange={(itemValue, itemIndex) => this.setState({ selectedTax: itemValue })}
                  items={this.state.taxRates.map(obj =>
                    ({
                      label: obj.name + ' ' + obj.rate + '%',
                      value: obj.rate,
                    })
                  )}
                  style={{
                    inputIOS: { color: 'gray' },
                    inputAndroid: { color: 'gray' },
                  }}
                />```
lfkwtz commented 4 years ago

look for itemKey in the docs