React SDK Quickstart - Stop Token Renewal redirecting to home route


In the React: Token Renewal tutorial, the renewSession function calls the setSession function. And the set session function has the following code in it.

 // navigate to the home route

this means, every time the session is renewed (e.g. page refresh), the route is changed to the home route.

This is not what I want, let’s say I’m currently in the route /profile, and I hit f5, how can I stop the navigation to the home route stemming from the renew token call? If I take the history.replace call out of setsession, the session is not actually renewed until page refresh.

Let me know a good way to achieve this.


Can anyone weigh in on this? Getting redirected back to the homepage in my app everytime I reload a page.

I removed this piece of code from the service as the service is not responsible for redirecting the user.
I moved it to the function that calls this service:

After login:

await Auth.setSession(...)

When checking if user is logged in:

await Auth.renewSession()
// the rest

Thanks a lot for sharing that @rgalite!