Skip to content

shouldThrow option for useParams not working #3482

Open
@grishbar

Description

@grishbar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions