TanStackT
TanStack17mo ago
36 replies
progressive-amaranth

Possible to make child route's `beforeLoad()` not run when parent route throws a redirect?

Given these routes:
* /accounts/$accountId/route.tsx
* /accounts/$accountId/settings/billing.tsx

We use route param placeholders so we can link to account routes from emails, e.g. to /accounts/_/settings/billing and we replace the _ value with the currently logged in $accountId.

We also have some logic in the BillingRoute's beforeLoad that checks if the account has access. It seems that despite a throw redirect() in the /accounts/$accountId's beforeLoad(), the code for the billing route is triggered, causing issues since _ isn't an actually valid ID.

Thoughts?
Was this page helpful?