T
TanStack•2mo ago
afraid-scarlet

Custom comparison method for loaderDeps

Hello, I'm trying to use a search param which serializes to bigint but I have troubles with loaderDeps: https://stackblitz.com/edit/tanstack-router-pajud2x2?file=src%2Froutes%2F__root.tsx&preset=node (click on About in nav)
Do not know how to serialize a BigInt
I see that the error is coming from the loaderDeps implementation which tries to JSON.stringify the search object. Is there a way to customize this behavior?
4 Replies
afraid-scarlet
afraid-scarletOP•2mo ago
As far as I can tell, it does not respect stringifySearch option from createRouter https://github.com/TanStack/router/blob/cd796fae0136b7bfd86b3b7c6b0d4b3679733fbc/packages/router-core/src/router.ts#L1217 Let me know if you want me to report a bug/feature request I see there's a this.options.stringifySearch() method called below https://github.com/TanStack/router/blob/cd796fae0136b7bfd86b3b7c6b0d4b3679733fbc/packages/router-core/src/router.ts#L1518C25-L1518C54 Maybe it could also be used here instead of JSON.stringify()?
exotic-emerald
exotic-emerald•2mo ago
hmm the root issue is that your validate search returns something that is not serializable (at least by JSON.stringify) i am not whether this is really supported
afraid-scarlet
afraid-scarletOP•2mo ago
I would argue that's what stringifySearch option is for, to customize what's serializable 😄 I can work on a PR if you're okay with my suggestion
exotic-emerald
exotic-emerald•2mo ago
sure, start with a minimal PR without tests just to see whether it works and how it feels / looks

Did you find this page helpful?