T
TanStack12mo ago
correct-apricot

General Navigation with Previous Search

When I do the following I get a TS error:
// product: 'apple' | 'banana' | 'orange'
const navigate = useNavigate({from: `/fruits/${product}`})
//...
const gotoDetails= () => {
// TS Error: prev is any
navigate({to: `/fruits/${product}/details`, search: (prev) => prev})
}
// product: 'apple' | 'banana' | 'orange'
const navigate = useNavigate({from: `/fruits/${product}`})
//...
const gotoDetails= () => {
// TS Error: prev is any
navigate({to: `/fruits/${product}/details`, search: (prev) => prev})
}
How do I properly type this? Take note that each product has its own search params that I would like to have carried over to the details page.
1 Reply

Did you find this page helpful?