T
TanStack2y ago
conscious-sapphire

Should I expect validateSearch to update the URL with the parsed query params?

Seems to do it on refresh but not when navigating with the Link component.
export const Route = createFileRoute('/_admin/admin/clients/')({
component: ClientList,
validateSearch: (search) => {
return { test: 1234 }
},
})
export const Route = createFileRoute('/_admin/admin/clients/')({
component: ClientList,
validateSearch: (search) => {
return { test: 1234 }
},
})
<Link to="/admin/clients">test</Link>
<Link to="/admin/clients">test</Link>
2 Replies
wise-white
wise-white2y ago
Hey! For reference, the objective of the validateSearch function is take whatever is provided, and then runs it against its schema to then pass down the validated values to the beforeLoad, loader, other dependent callbacks, and hooks. You may be looking for the preSearchFilters option, that sets some defaults.
export const Route = createFileRoute("/_admin/admin/clients")({
validateSearch: search => myValidateSearchSchema(search),
preSearchFilters: [
(search) => ({ test: search?.test || 1234 })
]
})
export const Route = createFileRoute("/_admin/admin/clients")({
validateSearch: search => myValidateSearchSchema(search),
preSearchFilters: [
(search) => ({ test: search?.test || 1234 })
]
})
conscious-sapphire
conscious-sapphireOP2y ago
Hey @Sean Cassiere that doesn't appear to be working for me. The URL is not updated when navigating with <Link> but does when refreshing the page. I'll try to make a reproduction

Did you find this page helpful?