pbeshai / react-url-query

A library for managing state through query parameters in the URL in React
https://pbeshai.github.io/react-url-query
MIT License
195 stars 38 forks source link

addUrlProps cached handlers #68

Open koshkarik opened 4 years ago

koshkarik commented 4 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? We use addUrlProps function in one of our components (it acts like filter by pushing attributes to url query). So when the component mounts for the first time - some handlers are stored in cache https://github.com/pbeshai/react-url-query/blob/master/src/react/addUrlProps.js#L223 and they are pointing to current instance https://github.com/pbeshai/react-url-query/blob/master/src/react/addUrlProps.js#L220. I apply some filters (query attributes are added to url). Then i go to some other section in our application, after that i come back. And already existing handlers from the cache get access to previous instance https://github.com/pbeshai/react-url-query/blob/master/src/react/addUrlProps.js#L180 . And this.props.location contains old irrelevant data and it gets pushed to url query.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.

What is the expected behavior? I think cashedHandlers should be cleared on unmount.

Which versions of react-url-query, and which browser and OS are affected by this issue? Did this work in previous versions of react-url-query? 1.5, Chrome 79, MacOS