1
How can I pick up hide a component when the bank result is completed.
Code:
import React, { Component } from 'react';
import axios from 'axios';
class Login extends Component {
state = {
user: '',
senha: ''
}
formLogin = () => {
console.log('carregando..');
axios.post('../../auth/login', {
email: this.state.user,
senha: this.state.senha
})
.then(resultado => {
if (!resultado.data.verifUser) {
console.log("Dados errado");
}
console.log('Terminou');
});
}
render() {
return (
<div className="Login">
<div className="form-group">
<label for="inputEmail">E-mail</label>
<input type="email" class="form-control" id="inputEmail" aria-describedby="emailHelp" placeholder="Digite seu email" onInput={(e) => this.setState({ user: e.target.value })} name="txtEmail" />
<small id="emailHelp" class="form-text text-muted">Informe o seu e-mail que foi cadastrado ou usuĂ¡rio</small>
</div>
<div class="form-group">
<label for="senha">Senha</label>
<input type="password" class="form-control" id="senha" placeholder="*******" name="txtSenha" onInput={(e) => this.setState({ senha: e.target.value })} />
</div>
<button type="submit" class="btn btn-primary" onClick={() => this.formLogin()}>Entrar</button>
</div>
);
}
}
export default Login;
Usually, if there is an incorrect user/password, the same page remains and somehow alerts the user of the error. If not then it is redirected to another page, a Dashboard, for example
– Costamilam
Freitas, could you rephrase your question so that it becomes clearer and more understandable? I want to help you but I don’t understand your question.
– Allan Andrade
Allan Andrade, I need when the request is triggered to trigger a loading div for the user to see, and when it is done, this div leaves
– Freitas