FormidableLabs / redux-little-router

A tiny router for Redux that lets the URL do the talking.
MIT License
1.04k stars 114 forks source link

Intentionally clearing a queryParam when `persistQuery` is true #223

Open adamesque opened 7 years ago

adamesque commented 7 years ago

It looks like there's no way to intentionally clear a queryParam when you're also persisting the existing query. It'd be great if I could do something like

push({
  pathname: '/messages',
  query: {
    filter: 'business'
    page: null
  }
}, {
  persistQuery: true
});

to wipe out the page param but keep any other queryParams that may have been set on the url.

This would make it easy to have implicit or default values for queryParams, so that we'd never have to explicitly include a param for ?page=1, for instance.

Does that seem reasonable? Filtering out params that are set but with null or undefined values? (We've also been mildly frustrated that empty string params are also passed through, but that may be a separate issue.)