T
TanStack13mo ago
rival-black

What would be the "more robust solution" instead of `await sleep(1)` for authenticated routes?

Hey, So I'm building a pretty similar auth to what's presented in authenticated-routes example. What caught me off guard is the await sleep(1) call after you log in (link). This is obviously to give React a chance to re-render so that isAuthenticated context state is up-to-date when AuthLayout's beforeLoad() is called (link). I'm struggling to find anything better though other than a getter that would read localStorage during beforeLoad() execution but I'd still prefer to use the in-memory React state for that purpose. What would you suggest for mentioned "more robust solution" in the comment?
1 Reply
deep-jade
deep-jade13mo ago
I would like to know too

Did you find this page helpful?