Want to make react-native Picker stay at newly selected option? On value change you need to specify which property of the state changed and change it accordingly with this.setState
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 | <Picker style={{ width: 100, }} selectedValue={(this.state && this.state.pickerValue) || 'a'} onValueChange={(value) => { this.setState({pickerValue: value}); }} itemStyle={{color: 'white'}}> <Picker.Item label={'Hello'} value={'a'} /> <Picker.Item label={'World'} value={'b'} /> </Picker> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.