T
TanStack2y ago
genetic-orange

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
protestant-coral
protestant-coral2y ago
the order of beforeLoad and validateSearchmatters
protestant-coral
protestant-coral2y ago
StackBlitz
Router Kitchen Sink Example (forked) - StackBlitz
Run official live example code for Router Kitchen Sink, created by Tanstack on StackBlitz
protestant-coral
protestant-coral2y 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.
genetic-orange
genetic-orangeOP2y ago
Thank you 🙏 this fixed the issue

Did you find this page helpful?