Why do we have to manage the state of the setSelected, won't it be better if you returned the selected value from the onSelect event.
i.e
<SelectList
onSelect={(selected) => console.log(selected)}
/>
Then I also noticed that the defaultOption triggers the setSelected which in turn triggers the onSelect. Confusing to the unsuspecting.
Why do we have to manage the state of the setSelected, won't it be better if you returned the selected value from the onSelect event.
i.e
Then I also noticed that the defaultOption triggers the setSelected which in turn triggers the onSelect. Confusing to the unsuspecting.