antd design select placeholder issues

FE_Addict picture FE_Addict · Aug 7, 2017 · Viewed 10.1k times · Source

I am using antd design in my React app.

Here's a code snippet where I am facing the issues :

<Select
     showSearch
     optionFilterProp = "children"
     placeholder = "Select Company"
     value = "{this.state.company}"
     name = "company"
     onSelect = "{this.handleCompanyChange}"
    >

Now it shows the correct value selected if this.state.company is not null. But if this.state.company is empty or null, placeholder doesn't shows up.

How can I solve this issue so that the placeholder appears if value is null?

Answer

afc163 picture afc163 · Aug 8, 2017

set this.state.company to be undefined instead of null.