I am missing an option to pass default params on to a route. It was requested a couple of times (#683, #1126), but the responses do not really solve the issue (defining a default prop "params" on the route component does not work).
The use case in my case:
<Route path="users" component={Users} title="User management">
<Route path="0" title="Create user" />
<Route path=":id" title="Edit user" />
</Route>
To be able to differ from create- and edit-operations within the route component, it would help a lot if i get a params.id = 0 within the "Create user" route component.
Proposal I:
Writing the default params within the path.
<Route path="users" component={Users} title="User management">
<Route path=":id=0" title="Create user" />
<Route path=":id" title="Edit user" />
</Route>
Proposal II:
Adding a prop "params" on routes. Params would be merged and populated to this.props.params of the route component. Params from the url would have precedence.
<Route path="users" component={Users} title="User management">
<Route path="0" params={{ id: 0 }} title="Create user" />
<Route path=":id" title="Edit user" />
</Route>
Just do something like
const { id = 0 } = props.params;
There's no particular need for it to be supported at the core library level.
Most helpful comment
Just do something like
There's no particular need for it to be supported at the core library level.