Closed Nr9 closed 3 months ago
@SeanCassiere The same thing happens to me, when I navigate between routes it goes fine, but when the component enters due to a redirect, if I try to get the context in that component, it is undefined and the app dies
example error:
export const Route = createFileRoute('/auth/verify-email')({
beforeLoad: async ({ context }) => {
if (!context.auth.id) {
throw redirect({
to: '/auth/verify-phone',
search: prev => ({ id: prev.id }),
viewTransition: true
});
}
if (!context.auth.needEmailVerification) {
if (context.auth.needPersonalInformation) {
throw redirect({
to: '/onboarding/require-legal-information',
search: prev => ({ id: prev.id }),
viewTransition: true
});
}
if (!context.auth.paymentMethods || !context.auth.paymentMethods.length) {
throw redirect({
to: '/payment-method/add-payment-method',
search: prev => ({ id: prev.id }),
viewTransition: true
});
} else {
throw redirect({
to: '/payment-method/select-payment-method',
search: prev => ({ id: prev.id }),
viewTransition: true
});
}
}
}
});
hook into paymentMethodComponent
export const useAddPaymentMethodForm = () => {
const { urlID, auth } = useRouteContext({ from: '/payment-method/add-payment-method' });
when it enters the before load of the verify email route, the contet works, but when I do the redirect it has to add card, in the addpaymentmethod hook it is undefined
I'm experiencing the same issue in the latest version
We have a PR open that should fix this #1713. We are waiting on some feedback from Tanner before merging it in.
@SeanCassiere I still have the same issue. Nothing changed.
And the main thing that I don't change context anywhere. I just set it and try to use helper functions from it. As a workaround I've made a patch using yarn to remove all functionality related to updating context. Something still overriding context with undefined
@SeanCassiere I still have the same issue. Nothing changed.
And the main thing that I don't change context anywhere. I just set it and try to use helper functions from it. As a workaround I've made a patch using yarn to remove all functionality related to updating context. Something still overriding context with undefined
Please create a new issue with a reproduction, I'd be happy to go through it next week!
Describe the bug
Another problem relating to undefined context.
I'm creating a new issue since I'm NOT using
defaultPreload: 'intent'
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-u41fay?file=src%2Froutes%2Ftests.%24testId.reports.create.tsx
Steps to Reproduce the Bug or Issue
/tests/$testId/reports
, url:http://localhost:3001/tests/42/reports/create
)Expected behavior
The
context
provided to theloader
function should not beundefined
.Screenshots or Videos
No response
Platform
Additional context
I do not have this problem with version
1.27.0
.