TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.02k stars 617 forks source link

useSearch issue: Undefined is not an object (evaluating 'opts.select') #2608

Open nathanaelphilip opened 7 hours ago

nathanaelphilip commented 7 hours ago

Which project does this relate to?

Router

Describe the bug

There seems to be an issue with this line of code: https://github.com/TanStack/router/blob/5cc2f9f1b0cb6b7ca4d2f19382b3f08d6f3daa60/packages/react-router/src/useSearch.tsx#L35

I didn’t get this error a few days ago. If I override the select option, it works. It seems like useParams also has the same issue.

Your Example Website or App

I can’t share

Steps to Reproduce the Bug or Issue

I’m not sure how to reproduce other than install the package and try using the useSearch hook.

Expected behavior

I shouldn’t get that error.

Screenshots or Videos

No response

Platform

Additional context

No response

nathanaelphilip commented 6 hours ago

If I change the code (in Chrome) to opts?.select it seems to work fine. Looks like it was there 10 months ago: https://github.com/TanStack/router/blame/7d8b9e0b9ce37ddfa4fe248554689700f45c5394/packages/react-router/src/useSearch.tsx And was removed here: https://github.com/TanStack/router/commit/41391cdd4a41ea5618b060e8a9437fbd83781719#diff-331972769223e304424bc9bad5163bb4e88e8dafeff6984b0e29d12dc2ae8b3a

schiller-manuel commented 1 hour ago

useSearch (and useParams) have a mandatory opts param, so you cannot just call useSearch()