TanStackT
TanStack2y ago
7 replies
ordinary-sapphire

Undefined context with useRouteContext

Hi !

I have an issue with the useRouteContext hook coupled with validateSearch in a nested route that throw an error in a specific situation.

In my application, there is an _auth route that ensure, in the
beforeLoad
method, that the user is logged in, returns his account's information if he is or redirects him to the login page if he's not.
There's also a route /_auth/events that can have three optional search params (
page
,
type
& criticality, by default,
1
, "all", "all"). When I navigate to /events from within the application, everything works as expected, the url change to /events?page=1&type=all&criticality=all as expected, but if I directly type /events in my browser, the url is also correctly updated, but I get the error below (
context
is
undefined
in the AuthLayout while being correctly logged in the
beforeLoad
method).

Did someone already faced this issue ?
auth.png
error.png
events.png
Was this page helpful?