Closed
Description
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 }