T
TanStack13mo ago
fair-rose

Typing params for top level routes that might have them?

Is it possible to type params that might exist at a higher level? Aim here is to swap cookie values if a specific param value changes
const appRoute = createRoute({
getParentRoute: () => rootRoute,
id: "app",
component: () => <AuthenticationGuard component={App} />,
beforeLoad: ({ context: { cookies }, location, params }) => {
// params?.userId
},
});
const appRoute = createRoute({
getParentRoute: () => rootRoute,
id: "app",
component: () => <AuthenticationGuard component={App} />,
beforeLoad: ({ context: { cookies }, location, params }) => {
// params?.userId
},
});
4 Replies
stormy-gold
stormy-gold13mo ago
The route itself will only ever receive params if the route its on has params. ie.
org.$orgId.tsx
org.$orgId.app.tsx <- has access to $orgId but not $userId
ord.$orgId.app.$userId.tsx
org.$orgId.tsx
org.$orgId.app.tsx <- has access to $orgId but not $userId
ord.$orgId.app.$userId.tsx
fair-rose
fair-roseOP13mo ago
Hmm, this app layout route I have is receiving children params Yup just logged params in this layout route and its receiving all params
app
- users/$userID
... other users/ routes
- /
app
- users/$userID
... other users/ routes
- /
stormy-gold
stormy-gold13mo ago
Either ways, it's not supported behaviors. You should only be working with route content upto that point, not beyond it
fair-rose
fair-roseOP13mo ago
Sounds good, will move this down to the parent of this param

Did you find this page helpful?