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.

wrong message when useMemo re-renders

See original GitHub issue

In the following case:

const A = () => {
   const obj = useMemo(() => ({
     // something big
  }), [a, b, c, d, e]);

 return <Child  obj={obj} />;
}

when the hook useMemo re-creates obj even if it’s deps deep equals, the message says A was re-rendered because if it, where in reality useMemo re-generated obj without a reason, but A is not re-rendered because of this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vzaidmancommented, Oct 14, 2020

@code-guru @Hypnosphi released a fix in version v5.0.0-rc.1

1reaction
vzaidmancommented, Oct 14, 2020

this guy built a whole library around it: https://github.com/alexreardon/use-memo-one

Read more comments on GitHub >

github_iconTop Results From Across the Web

React useMemo re-render issue - Stack Overflow
What useMemo does is after a rerender occurs, it compares the values in it's dependency array, if they didn't change then the last...
Read more >
How To Avoid Performance Pitfalls in React with memo ...
Step 1 — Preventing Re-renders with memo · Step 2 — Caching Expensive Data Calculations with useMemo · Step 3 — Managing Function...
Read more >
You're overusing useMemo: Rethinking Hooks memoization
In some cases, useMemo is irrelevant, overused, and harmful to your application performance. Learn these situations and how to avoid them.
Read more >
How to useMemo and useCallback: you can remove most of ...
One single mistake and it all falls apart and makes those hooks useless. Remove them if you find them.
Read more >
When does React re-render components? - Felix Gerschau
If we want to understand how React renders and re-renders work, ... only happen once in the Tile component that displays the message:....
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