I'm trying to logout using this method: In render I have a div like this:
<div>
<a href="#" onClick={this.logout()}>LOGOUT</a>
</div>
and the logout function:
logout() {
// localStorage.clear();
location.href = 'localhost:3000';
}
At localhost:3000 I have the login page.
Put when I press logout, nothing happends. What can I do? Thank you
Login page in ReactJS designFirstly, we will make a form - that will have fields of email and password. After this, there will be a button to submit the information filled in these fields. Basically, it is the information that is sent to the backend for validation.
If you'd like to sign the user out of their current authentication state, call the signOut method: import auth from '@react-native-firebase/auth'; auth() . signOut() .
this solved my problem
logout() {
localStorage.clear();
window.location.href = '/';
}
Give to us the Minimal Example to be tested.
You already checked if your function is being called? Try to put some console.log
inside logout()
, it smells Binding to methods of React class issue.
Try to insert http:// inside location.href, like this: location.href = 'http://localhost:3000';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With