I want to show the option selected by the user in console in Select tag but as user select test1 console show me undefined and when user select test 2 then it show me previous selected value that is test1 and so on.
Component.jsx
<Form.Group controlId="exampleForm.ControlSelect1">
<Form.Label>Login as</Form.Label>
<Form.Control as="select" defaultValue="test1" onChange={getOptionValue} >
<option>test1</option>
<option>test2</option>
<option>test3</option>
</Form.Control>
</Form.Group>
useState
const [getOption, setOption] = useState();
const getOptionValue = (e) => {
setOption(e.target.value);
console.log(`here is selected option${getOption}`);
}