DropDown with ShowClear enabled show clear button on load

UI Components for React
Post Reply
Posts: 2
Joined: 09 Sep 2020, 10:07

09 Sep 2020, 11:17

I am using PrimeReact's Dropdown control with showClear enabled.
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) {
		this.state = {
			cities: [],
			city: ''
	public componentDidMount() {
		this.getCityOptions().then(results => {
			this.setState({ cities: results });
	public render(){
		return (
				onChange={(e) => this.setState({ city: e.value })}
				placeholder="Select City" 

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests