I want to remove the user Authentication when the tab that had my Application closed in any browser. And when the user loads the Application again in the new tab they should not see any of their details until logging in again. Is there any way to implement this concept in React?
CodePudding user response:
If you are storing in LocalStorage, replace it to SessionStorage.
CodePudding user response:
Add this to App.js
For functional component :
useEffect(() => {
return () => {
localStorage.clear()
}
})
for Class Component :
componentWillUnmount() {
localStorage.clear()
}