Tengo un formulario que intento vincular el evento "submit" para que me muestre un alert con el valor del input password.
El evento submit funciona porque recibo un alert vacio, pero no me muestra el valor.
import React, { Component } from "react";
import { Button , Form } from 'react-bootstrap';
export default class Profile extends Component {
constructor(props) {
super(props);
this.password = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Password was submitted: ' + this.password.value);
event.preventDefault();
}
render() {
return (
<div>
<Form>
<Form.Group controlId="formBasicPassword">
<Form.Label>Password</Form.Label>
<Form.Control type="password" id="password" name="password" placeholder="Password" />
</Form.Group>
<Button onClick={this.handleSubmit}>Enviar</Button>
</Form>
</div>
);
}
}