T
TanStack3y ago
passive-yellow

useParams arguments no longer optional

I was using the beta version 169, and I was able to get the current path parameters with const params = useParams(). After bumping to version 179, this function call is no longer valid. Reviewing the code, it looks like opts was changed from optional to required. Was this intentional? If so, what is the new syntax if I just want to get the current matching parameters of a page?
3 Replies
exotic-emerald
exotic-emerald3y ago
Where are you getting useParams? Export? route.useParams? Component props?
passive-yellow
passive-yellowOP3y ago
import { useParams } from '@tanstack/react-router';
import { useParams } from '@tanstack/react-router';
exotic-emerald
exotic-emerald3y ago
Yeah that wasn’t type safe until now. If you know the route it’s being called inside of, provide the “from” option to it. If you don’t know, pass the “strict: true” option.

Did you find this page helpful?