T
TanStack8mo ago
yelping-magenta

is there anything wrong with wrapping `getRouteApi(...).use<whatever>` in try/catch

i want to be able to generically grab stuff from the url, and the nicest way feels like getting this data from the relevant Route params in my case if you call useParams on a non active route, this throws. any issue with effectively turning this into a result type of <RouteParams, Error>? perf issues, or some footgun i've not considered?
2 Replies
rare-sapphire
rare-sapphire8mo ago
You can pass shouldThrow: false to useParams so it won’t throw on non-active routes. It’s powered by useMatch under the hood.
yelping-magenta
yelping-magentaOP8mo ago
Awesome, thank you

Did you find this page helpful?