I am getting duplicate values from the select option in an edit form. For example, in the select option, I have A and B, and let say I have in the database recorded as B. So when I go into the edit form I should see B being selected which working fine so far. But I see A, B, B instead of A and B.
I am not sure how do I get rid of the duplicate values. Here is the code:
<div className="col-sm-10">
<select id="sourcename" className="form-control" name="source" onChange={handleChange}>
{sourceData.map(option => (
<option value={option._id}>{option.sourcename}</option>
))}
<option selected value={data.source._id}>{data.source.sourcename}</option>
</select>
</div>
Many thanks in advance and greatly appreciate any helps. Thanks