I saw on a website that we can see when a use try to refresh the page ( using F5 or clicking the refresh button ) in this way:
if (performance.navigation.type === 1)
My question is: Let's say the user don't refresh the page but he type another URL to my other page. How can I get that event?
I say that because I have stored in my Redux state if user is logged in. When the page is type another URL, my state is lost. So, I want to catch that moment and check if I have a token in localstorage.
CodePudding user response:
Just delete that condition and put code in a useEffect and will work no matter if you refresh the page or type the url.
UseEffect will be triggered on any render.