T
TanStack3y ago
afraid-scarlet

onLoad only runs once

Hi all, I'm wondering if there is a more clean way to approach following scenario. I have an app with an admin user and a normal user. I pass this user to my route context. On my layout route I check my user's role to allow it to certain routes or redirect him when it lacks permissions. On logging out I set this user to undefined. This all works fine the first time the app loads. For example when I log in with the admin and log out again. Then login with the normal account I land on the admin page as the onLoad function in my layout route does not get called again, hence I don't get redirected. Why does the onload only get called once? As a temporary workaround I redirect after logging out using window.location.replace('/') this works as it forces a refresh thus forcing the onload function to run again after logging in. Is this intended behaviour or are there any other options to solve this? tldr; onLoad only gets called once, do I have other options to check my user for permissions before entering a route other than the onLoad function, without forcing a refresh between logons?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?