TanStackT
TanStack2y ago
12 replies
dead-brown

How to get typed routeMatch

Hi.

I'm using matches from useRouterState and need to get typed match for some of them.

I'm trying to use that :

for(const match of matches) {
  switch (match.routeId) {
    case '/app/products/$productId':
    match.params.productId;
  }
}


But the problem is that typescript says that match.params does not include productId. How can I get the productId param in this case ?
Thank you.
Was this page helpful?