window.location.reload() logout from react

I need quick route to logout my user who is stored in localStorage.
I came with this solution but on mobile device is nonstop refreshing
page and not log out as expected. One of my routes is checking if
user is in localStorage and according render component.
I need this logout because I am developing mobile version of page
and can’t click on logout link (its momentally because of css overlapping),
which has same logic, so its hard to tell where is problem. So I set up
logout on /logout route. There are 535 ways to reload
js but no way works

This is my logOut. On Desktop perfecly fine, I think that its because it is in render() method
but not quite sure, can somebody help?

const logOut = () => {

       <Route path='/logout' render={()=> {logOut()}}/>

103 thoughts on “window.location.reload() logout from react”

Leave a Comment