I have a drop down menu in react where the state changes if I select the second item in the menu but if a change the menu back to the first item the state does not update unless i choose the second item twice. I have tried placing the code in a useEffect with colorDrop in the dependency array but it still does not work correctly. Here is my code if anyone has any idea how to fix this issue.
currentArray = ["blue", "grey"]
const [colorDrop, setColorDrop] = useState(currentArray[0])
function Dropdown() {
return (
<div>
<form>
<label>Color</label>
<select required onChange={(e) => setColorDrop(e.target.value)}>
{currentArray.map((item, iter) => {
return (
<option key={iter}>{item}</option>
)
})}
</select>
</form>
</div>
)
}