How to access router
in beforeLoad()
?
#4865
Unanswered
Albert-Gao
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
for this doc:
https://tanstack.com/router/latest/docs/framework/react/guide/authenticated-routes#redirecting
it says:
Since we'll be replacing the entire URL with what it was, router.history.push is better suited for this than router.navigate: > router.history.push(search.redirect)
But here is the problem, we are in the
beforeLoad()
, and I can NOT find any router from the ctx parameter, so how do we do this, write this as anuseEffect
in thecomponent
? so we can access therouter
viauseRouter
?Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions