T
TanStack15mo ago
yammering-amber

beforeLoad / validateSearch compatibility issue?

I'm wondering if it's intentional that when utilizing code-based routing, if one attempts to utilize any parameters provided to beforeLoad (e.g. context) that the type of search parameters provided via inference validateSearch is dropped in consumers utilizing useSearch? If not, how might one leverage beforeLoad with provided parameters without losing the type inference for search parameters on the same route? Minimal Repro: https://stackblitz.com/edit/tanstack-router-nrzryj?file=src%2Fmain.tsx
Dylan Klohr
StackBlitz
Router Kitchen Sink Example (forked) - StackBlitz
Run official live example code for Router Kitchen Sink, created by Tanstack on StackBlitz
4 Replies
vicious-gold
vicious-gold15mo ago
the order of beforeLoad and validateSearchmatters
vicious-gold
vicious-gold15mo ago
StackBlitz
Router Kitchen Sink Example (forked) - StackBlitz
Run official live example code for Router Kitchen Sink, created by Tanstack on StackBlitz
vicious-gold
vicious-gold15mo ago
Total TypeScript
Sometimes, Object Property Order Matters
Learn why the order you specify object properties in TypeScript matters and how it can affect type inference in your functions.
yammering-amber
yammering-amberOP15mo ago
Thank you 🙏 this fixed the issue

Did you find this page helpful?