This code works:
<button onClick={props.action}> Sign in </button>
This code doesn’t work:
<button class="btn btn-outline-primary" type="button" onClick={() => logIn(username, password).then((res) => res.data===0 ? props.action : console.log(res.data) )}> Sign in </button>
I’m new to reactjs Does any body know why it doesn’t work in the second way?
Advertisement
Answer
Just a tip; Make a function and then call the funciton onClick instead. The code gets simpler to read!