If you throw a redirect in the beforeLoad of page A, then navigate back to page A (without the redirect being thrown), loader receives an undefined context.
I discovered this because I am working on a project where the client needs to complete a setup step. If they navigate to /page, I fetch the setup status in the beforeLoad and redirect them to /setup if required. I noticed that when the user is redirected, if I try to navigate back to /page after setup is complete, then the page's loader context is undefined.
Notice you are on the About page. If you look in the console, you were redirected on initial load.
Press the "Navigate" button.
Notice you are on the Index page. If you look in the console, you will see that the loader context is undefined.
Expected behavior
Open the DevTools console.
Notice you are on the About page. If you look in the console, you were redirected on initial load.
Press the "Navigate" button.
Notice you are on the Index page. If you look in the console, the loader context is an object containing the queryClient
After navigating to a page that has been redirected from, the loader context should not be undefined. We are suggested by the docs / examples to use loader: ({ context: { queryClient }) => {} when defining loaders, which is not valid if context can be undefined.
Describe the bug
If you throw a redirect in the
beforeLoad
of page A, then navigate back to page A (without the redirect being thrown),loader
receives an undefined context.I discovered this because I am working on a project where the client needs to complete a setup step. If they navigate to
/page
, I fetch the setup status in thebeforeLoad
and redirect them to/setup
if required. I noticed that when the user is redirected, if I try tonavigate
back to/page
after setup is complete, then the page's loadercontext
is undefined.Your Example Website or App
https://stackblitz.com/edit/github-xhruej?file=src%2Froutes%2Fabout.tsx,src%2Froutes%2Findex.tsx&file=src%2Froutes%2Fabout.tsx
Steps to Reproduce the Bug or Issue
undefined
.Expected behavior
queryClient
After navigating to a page that has been redirected from, the loader context should not be undefined. We are suggested by the docs / examples to use
loader: ({ context: { queryClient }) => {}
when defining loaders, which is not valid if context can be undefined.Screenshots or Videos
No response
Platform
Additional context
No response