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

[Bug]: Params type incomplete #12373

Open
lensbart opened this issue Nov 24, 2024 · 0 comments
Open

[Bug]: Params type incomplete #12373

lensbart opened this issue Nov 24, 2024 · 0 comments
Assignees

Comments

@lensbart
Copy link

What version of React Router are you using?

7

Steps to Reproduce

The params argument is typed according to the route itself. In prior versions of Remix, useParams() would return all params in the current URL, i.e. also those from child routes which may or may not be rendered. The params prop passed to the default route export doesn’t have this in its type signature. I’m not sure about the actual runtime behaviour since I haven’t been able to complete the migration of our app to RRv7.

Expected Behavior

If :someId is present in the params for a given layout route, and :someOtherId is present in the params of a child route, I would expect the type signature of the layout route to be either

type Params = { someId: string } | { someId: string; someOtherId: string }

or

// this approach won’t scale well with multiple child routes that each take different params
type Params = { someId: string; someOtherId?: string }

Actual Behavior

type Params = { someId: string }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants