You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using stringifySearchWith as stringifySearch option on the router instance with just the first argument supplied, strings do not get passed to the stringify method if not given a 2nd undocumented (https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization) parse method. By default JSON.parse is getting passed in there which results in strings only containing numbers to be encoded as "123" instead of just 123. A few weeks ago I supplied a custom stringifySearchWith to simply support encoding Set instances as well. This changed the behavior of how strings are encoded which in the end led to numeric string params to be ignored completely as I had a Zod validator defined with .string().optional().catch(undefined). Removing the .catch(undefined) revealed that it was receiving a number instead of a string.
Difficult to say. I saw that this 2nd parse argument was introduced in #654 but I don't really understand the background. At least this 2nd parameter should get documented or if not given, stringify should still be called?
Screenshots or Videos
TanStack.Router.Stringify.Search.mp4
Platform
OS: macOS
Browser: Edge
Version: 1.95.3
Additional context
No response
The text was updated successfully, but these errors were encountered:
Which project does this relate to?
Router
Describe the bug
When using
stringifySearchWith
asstringifySearch
option on the router instance with just the first argument supplied, strings do not get passed to thestringify
method if not given a 2nd undocumented (https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)parse
method. By defaultJSON.parse
is getting passed in there which results in strings only containing numbers to be encoded as"123"
instead of just123
. A few weeks ago I supplied a customstringifySearchWith
to simply support encodingSet
instances as well. This changed the behavior of how strings are encoded which in the end led to numeric string params to be ignored completely as I had a Zod validator defined with.string().optional().catch(undefined)
. Removing the.catch(undefined)
revealed that it was receiving a number instead of a string.Your Example Website or App
https://stackblitz.com/edit/github-qmrnwt4n?file=src%2Fmain.tsx
Steps to Reproduce the Bug or Issue
stringifySearch
from router and reloadExpected behavior
Difficult to say. I saw that this 2nd
parse
argument was introduced in #654 but I don't really understand the background. At least this 2nd parameter should get documented or if not given,stringify
should still be called?Screenshots or Videos
TanStack.Router.Stringify.Search.mp4
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: