193
rated 0 times
[
194]
[
1]
/ answers: 1 / hits: 21454
/ 4 Years ago, thu, july 30, 2020, 12:00:00
I am trying to get the value of a form input using React-Bootstrap. What is the standard procedure to get the form value from a react bootstrap form on a functional component in react?
export default function SpouseForm() {
const dispatch = useContext(DispatchContext);
return (
<Form>
<Row>
<Col xs={12} md={12} lg={{ span: 6, offset: 3 }}>
<InputGroup className="mb-3">
<InputGroup.Prepend>
<InputGroup.Text>Age</InputGroup.Text>
</InputGroup.Prepend>
<FormControl /> <--------- I want to get this value on submit /////////////////
</InputGroup>
</Col>
</Row>
<Row>
<Col xs={12} md={12} lg={{ span: 6, offset: 3 }}>
<Button
onClick={(e) => {
e.preventDefault()
dispatch({ type: "SPOUSE_AGE", spouseAge: e.target.value }); < ----- tried to get it here, not working
router.push('/children')
}}
style={{ width: '100%' }}
type="submit"
variant="outline-primary"
size="lg" >Next</Button>{' '}
</Col>
</Row>
</Form>
)
}
More From » reactjs