I am new to learn react native. I want to get selected value from dropdown in react-native.
my constructor
constructor(props){
super(props);
this.state = ({
PickerSelectedVal : ''
})
}
in render
render(){
<Dropdown
label="Select"
options={["Op1","Op2"]}
selectedValue={this.state.PickerSelectedVal}
onSelect={(obj)=>this.changedemo({obj})}
/>
}
in function
changedemo= (ob)=>{
this.setState({PickerSelectedVal : ob});
alert("Selected country is : " +ob.PickerSelectedVal);
console.log(this.state.PickerSelectedVal);
if (this.state.PickerSelectedVal === 1) {
alert("Selected value is : " +ob.PickerSelectedVal);
}
if(this.state.PickerSelectedVal === 0) {
alert("Selected value is : " +ob.PickerSelectedVal);
}
}
I have tried many times. I want to get selected value from dropdown alert is also showing but it prints. Selected value is:undefined.