I'm new to react native. I have made dropdown list but i want one reset button whenever i click it reset the default label. Here is my code of simple dropown list.I want one reset button.
<Picker
style={{width:'80%'}}
selectedValue={this.state.PickerValue}
onValueChange={(itemValue,itemIndex) =>
this.setState({PickerValue:itemValue})}>
<Picker.Item label="Select a option" value=""/>
<Picker.Item label="Html" value="html" />
<Picker.Item label="Javascript" value="javascript"/>
</Picker>
While I have no experience with Picker, setting the value of your dropdown using a button can be done by doing this:
setDropdownValue = () => {
document.getElementById("languagePicker").selectedIndex = "0";
};
<button onClick={this.setDropdownValue}>Reset selected picker value</button>
Dont forget to replace:
<Picker
to
<Picker id="languagePicker"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With