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.15k stars 96 forks source link

URL path getting decoded when calling setQuery #192

Closed i11ltech closed 2 years ago

i11ltech commented 2 years ago

When calling setQuery the URL path gets decoded which breaks the API call because of the special char. http://localhost:3000/articles/abc%5B0%5D?x=3 , gets converted to http://localhost:3000/articles/abc[0]?x=3

Example: ` const [query, setQuery] = useQueryParams({ x: NumberParam, ..... });

setQuery( { x: 22 ,... ) `

When setQuery gets called the URL gets updated with decoded path, when stepping through the code the line where the conversion happens is in useQueryParams.js line 115: deps.setLocation(encodedChanges, updateType)

It looks like the location object is decoding the path. There are functions to encode the params but not the path. Please advice.

pbeshai commented 2 years ago

I believe this has been fixed in v2.0.0-rc.0. Let me know if you have any issues. See the changelog for migration info.