'select list returns previous value after closing and reopening
I have a list and I choose a value from the list.
For example "Mercedes".
But I close this list with the "Save" or "Close" button and when I open it again, "Mercedes" is selected. How can I prevent this?
<Modal isOpen={app.showCars} >
<ModalHeader>
</ModalHeader>
<ModalBody>
<Select
options={carList}
onChange={(car) => (app.addcar = car)}
value={app.addcar }
/>
</ModalBody>
<ModalFooter>
<Button onClick={() => {
app.addcar()
app.showCarModal = false;
}}>Save</Button>
<Button onClick={() => {
app.showCarModal = false;
}}> Close </Button>
</ModalFooter>
</Modal>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
