Unnecessary re-renders using useQueryParams
See original GitHub issueHey again @kyeotic 👋
I am currently investigating some performance issues we are experiencing when changing URL parameters with useQueryParams
.
I am finding issues within our own code but also what I think could be issues in raviger
.
For instance, I have found this and I am not sure if it’s an issue or a feature request: Code Sandebox
Whenever setting the same values for the parameters, the RouterContext.Provider
value changes, causing the components consuming the context to re-render.
The problem is here: router.js#L32
Each render loop generates a new object reference passed to the context provider, the value is not memoized with useMemo
, and there is nothing that checks for deep equality of the parameters to prevent passing a new object reference either.
Additionally, pushing the same query params still pushes a new history state, and I am not sure if that is expected or a bug?
Issue Analytics
- State:
- Created 4 years ago
- Comments:26 (26 by maintainers)
Top GitHub Comments
I just meant you’d have a hard time making a sandbox repo with the version unpublished from npm.
I’ve tried a few different setup and I still cant get the failure from #34. I’ve got to handle something else, but if you get me a repro tonight I will make sure it gets fixed.
No worries at all, I totally understand. Hope your releases are all going smoothly 😃