optgroup label is repeating on droplist
this is the dropdown
<Input
id="period"
name="period"
type="select"
required
onChange={handleChange}>
<option disabled selected>
Please Select
</option>
{periodLists.map((item) => (
<optgroup label={item.period_category}>
<option
key={item.id}
value={item.period_name}>
{item.period_name}
</option>
</optgroup>
))}
</Input>
You are creating a separate
optgroupfor each item.You need to have two nested loops, an outer loop for the groups and an inner loop for the items.