question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unnecessary re-renders using useQueryParams

See original GitHub issue

Hey 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:closed
  • Created 4 years ago
  • Comments:26 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
kyeoticcommented, Jan 10, 2020

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.

0reactions
kyeoticcommented, Feb 25, 2020

No worries at all, I totally understand. Hope your releases are all going smoothly 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

My component keeps rerendering while using a path param
The component doesn't rerender and I just get the data, but for some reason when I use it with path params it goes...
Read more >
React Hooks | Everything I know - My Knowledge Wiki
useQueryParams - React Hook for managing state in URL query parameters with ... fp-ts-react-stable-hooks - Reduce unnecessary rerenders when using fp-ts ...
Read more >
How to debug unnecessary rerenders in React | Bryce's Blog
To use this tool, simply install Profiler and turn on the “Record why each component rendered while profiling.” option. You can then run ......
Read more >
use-query-parameters - npm
Possibility to define scheme of query parameters for one time · Watch for only needed params · Don't provoke extra rerenders · Parsing...
Read more >
React I love you, but you're bringing me down - Hacker News
I primarily agree with you, but his primary point is mainly regarding the tendency ... you get exactly the data you request, no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found