react-component / m-picker

React Mobile Picker(web & react-native)
http://react-component.github.io/m-picker/
247 stars 73 forks source link

Bug: if props are updated except selectedValue, Picker's selectedValue will have the value of first Picker.Item. #210

Open wonism opened 4 years ago

wonism commented 4 years ago
{/* if component props will be changed like below. */}

<Picker
  defaultSelectedValue={0}
  selectedValue={someAwaitingValue /* it is undefined yet. */}
>
  {items}
</Picker>

{/* vvvvvvvvvv */}

<Picker
  defaultSelectedValue={1}
  selectedValue={someAwaitingValue /* it is undefined yet. */}
>
  {items}
</Picker>

The condition for updating this.state.selectedValue is currently 'selectedValue' in nextProps. This causes select method will update the selectedValue to be the first value of Picker.Item.