Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shouldThrow option for useParams not working #3482

Open
grishbar opened this issue Feb 19, 2025 · 2 comments · May be fixed by #3642
Open

shouldThrow option for useParams not working #3482

grishbar opened this issue Feb 19, 2025 · 2 comments · May be fixed by #3642
Labels
enhancement New feature or request

Comments

@grishbar
Copy link

Which project does this relate to?

Router

Describe the bug

My current route - '/'
Im trying to get page params like this:

const route = getRouteApi('/_auth/users/$userId')

export function UsersList() {
  const { userId } = route.useParams({ shouldThrow: false })
  ...
}

but im getting error - Error: Invariant failed: Could not find an active match from "/_auth/users/$userId"
Image

Also types for shouldThrow prop are wrong, it accepts only true but shoud accept any boolean value
Image

Expecting behavior, that im just get undefined in my userId value

Your Example Website or App

Steps to Reproduce the Bug or Issue

  1. go to '/' url in your project
  2. Call useParams with { shouldThrow: false } prop for another route for example '/users/$userId'
  3. get the error

Expected behavior

expected not getting arror just get undefined value

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: latest

Additional context

No response

@atev1l
Copy link

atev1l commented Feb 19, 2025

i have this problem too

@schiller-manuel
Copy link
Contributor

Also types for shouldThrow prop are wrong, it accepts only true but shoud accept any boolean value

the types are not wrong here
RouteApi does not support shouldThrow: true yet

@schiller-manuel schiller-manuel added the enhancement New feature or request label Mar 2, 2025
@schiller-manuel schiller-manuel linked a pull request Mar 3, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants