Ideally the control should show clear button only when some option in selected but the control shows clear on control load also even when no value is selected.
Once the user selects some option then tries to clear the selected option then it works fine but the issue is in onload.
Code: Select all
export default class selectCityComponent extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = {
cities: [],
city: ''
};
}
public componentDidMount() {
this.getCityOptions().then(results => {
this.setState({ cities: results });
});
}
public render(){
return (
<Dropdown
value={this.state.city}
options={this.state.cities}
optionLabel="CITY_NAME"
optionValue="CITY_NAME"
onChange={(e) => this.setState({ city: e.value })}
placeholder="Select City"
/>
);
}
}