Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some react elements like Button don't allow for state changing. #12

Open
moda20 opened this issue Aug 17, 2019 · 0 comments
Open

Some react elements like Button don't allow for state changing. #12

moda20 opened this issue Aug 17, 2019 · 0 comments

Comments

@moda20
Copy link

moda20 commented Aug 17, 2019

I encountered a problem with some elements not accepting the state change in the onClick event.

example :

<Button onClick={(event)=>{
     this.login(event)
 }}>Log In</Button>
 login(e) {

    e.preventDefault();
    this.setState({
      isLoading:true
    });
    // Here, we call an external AuthService. We'll create it in the next step
    Auth.login(this.state.user, this.state.password)
      .catch(function (err) {
        console.log("Error logging in", err);
      }).finally(()=>{
      this.setState({
        isLoading:true
      });
    });
  }

the setState call on first doesn't happen. no matter what happens it doesn't change the state to true. It even passes when using callback function in the setState method.
This happened multiple times and using other components did fix the problem.

is this a bug ? how can I fix it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant