It seems currently there's no way to have default query params. The use case is the following:
this.context.router.transitionTo('users', null, {page: 1})
Currently it generates a path similar to /users?page=1. However, it would be nice to specify page=1 being the default and so the generated path woudl just be /users.
Since you already have the nice <Router/> syntax for configuration, I think we can extend it like below:
<Router name="users" defaultParams={{page: 1}} />
Frank
+1 for default route query params
+1 here too, should also work with redirects..
UseCase:
<Redirect
from='old/route/that/contains/just/one/:parameter'
params={{newRouteParameter:1, secondNewRouteParameter:2}}
to='newRouteThatHasMoreThenOneParameter'} />
right now this does not work, I expected the parameters to be combined (like Object.assign()).
+1
For default params on a route just have a params default prop on your route component
If we used Object.assign() for redirects, how would you opt-out of the merge if you wanted to replace?
In 1.0 you have onEnter at the route level, so you could do whatever logic you want to perform a redirect :)
@ryanflorence "For default params on a route just have a params default prop on your route component"
How would I go about doing this? Thanks in advance.
Most helpful comment
@ryanflorence "For default params on a route just have a params default prop on your route component"
How would I go about doing this? Thanks in advance.