pbeshai / use-query-params

React Hook for managing state in URL query parameters with easy serialization.
https://pbeshai.github.io/use-query-params
ISC License
2.13k stars 95 forks source link

Preventing history push when setQuery didn't actually result in any url changes #234

Closed PEsteves8 closed 1 year ago

PEsteves8 commented 1 year ago

Hi,

The library works great, but I'm using a custom adapter to compare the state of the URL before actually allowing a navigatecall.

The thing is that it's sometimes easier to just call setQuery in certain circumstances without worrying about whether or not anything changed. The issue is that this creates history entries that don't do anything. So sometimes after rendering a screen, to go back, you'd have to hit back a few times before actually reaching the real previous url state.

My current solution works well, but I'm wondering if this feature is available and I haven't found it, or if it's deliberately been left out for some technical reason. Or maybe I'm just not designing my features ideally and this isn't really a need if one designs things properly.

Thanks for your work, Paulo

pbeshai commented 1 year ago

Good idea, thanks! Added in v2.1.0

PEsteves8 commented 1 year ago

Wow that was fast haha. Thanks!