T
TanStack8mo ago
fascinating-indigo

Dynamic value of useSearch() from?

Hello, I'd like to create a custom hook that uses useSearch() hook with with full type-safety. I have 2 almost identical pages, with same search params and I'd like to use this hook only there. Is it possible to allow the useSearch to look either for one or the other one URL as 'from'?
3 Replies
sunny-green
sunny-green8mo ago
i had a similar problem and just added a from parameter to the custom hook, that accepts the url of those routes and then pass it to useSearch
afraid-scarlet
afraid-scarlet8mo ago
yeah sounds like a good solution
robust-apricot
robust-apricot8mo ago
@ilarramendi What was the type you gave your from parameter?

Did you find this page helpful?