In My react application. When i click logout button. it open a confirm alert. if i confirm it i will logout from my application. whenever i cancel it it also redirect to my login route. I want the route will be the same when i will cancel it. How can i do it? My code is:
Code Screenshot Client Site Screenshot
const logOut = () => {
const confirm = window.confirm('Are you sure to logout?');
if (confirm) {
signOut(auth)
}
}
You can add else statement for the required purpose. Following code demonstrate the purpose:
const logout = () => {
const confirm = window.confirm("are you sure?");
if(confirm){
window.location.href = "http://www.w3schools.com";
}else {
// same as clicking a link
// not optimal solution though
window.location.href = window.location.href;
}
}