TanStackT
TanStack2y ago
10 replies
sour-pink

`loader` function doesn't have access to `context` after being redirected to

I load a route and check some things in the
loader
function. If it errors, I throw redirect to another route. That route, however, doesn't seem to have access to the context in its
loader
function.

routes/offers.tsx
...
loader: () {
  try {
    // some api call
  } catch (err) {
    throw redirect({ to: "/", search: { error: "missing_offer" } });
  }
}
...


routes/index.tsx
loader: async ({ deps, context, location }) => {
  console.log("loader", context); // loader is undefined!
}
Was this page helpful?