wrong message when useMemo re-renders
See original GitHub issueIn 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:
- Created 4 years ago
- Comments:22 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@code-guru @Hypnosphi released a fix in version v5.0.0-rc.1
this guy built a whole library around it: https://github.com/alexreardon/use-memo-one