I have an array of values, and i am looping the array to display in Select Option
<Form.Item label="Status">
<Select
value={user.status}
onChange={handleStatusChange}
>
{status.map((item, index) => (
<Select.Option key={index} value={item.status}>
{item.name}
</Select.Option>
))}
</Select>
</Form.Item>
I want to "None" to be displayed by default when nothing is selected or when the value of the mapped item is null.
In other words, i want none to be the selected option when status
is null
or undefined
.
I am using antd
2
Answers
To display an empty value, you will have to add
displayEmpty
to the Select, combined withrenderValue
.You can return the corresponding noption depending on the element value:
or just