T
TanStack3mo ago
other-emerald

access 'previous' state of search params?

i'm trying to create a util roughly like
function withPreviousSearch(fn: (prev: <existing params for the route>) => <search key i'm updating>) {
void navigate({
search: (prev) => ({
...prev,
filters: { ...prev.filters, ...search },
}),
});
}
function withPreviousSearch(fn: (prev: <existing params for the route>) => <search key i'm updating>) {
void navigate({
search: (prev) => ({
...prev,
filters: { ...prev.filters, ...search },
}),
});
}
i just can't get a proper type for the withPreviousSearch. ReturnType<typeof Route.useSearch> returns any
2 Replies
other-emerald
other-emerald3mo ago
Type Utilities | TanStack Router React Docs
Most types exposed by TanStack Router are internal, subject to breaking changes and not always easy to use. That is why TanStack Router has a subset of exposed types focused on ease of use with the in...
other-emerald
other-emeraldOP3mo ago
this could possibly work, thank you

Did you find this page helpful?