10.0.0-alpha.1 - Component returned from useMemo renders when nothing has changed
See original GitHub issueI was searching for an alternative to shouldComponentUpdate
when I discovered that useMemo
always executes it callback (tested with an empty array and a hard value in array).
In this codesandbox you can see the difference between React and Preact where one renders a single time and the other multiple times (output in console).
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
10.0.0-alpha.1 - Component returned from useMemo renders ...
I was searching for an alternative to shouldComponentUpdate when I discovered that useMemo always executes it callback (tested with an empty ...
Read more >React useMemo re-render issue - Stack Overflow
useMemo will prevent a new instance of the component being created and will not stop it from re-rendering if props didn't change.
Read more >Hooks API Reference - React
useMemo will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every...
Read more >React.memo() vs. useMemo(): Major differences and use cases
Learn what memoization is, how it works in React, and why React has two ... a component change, the entire component re-renders by...
Read more >Why React Re-Renders - Josh W Comeau
It's the only “trigger” in React for a component to re-render. ... it sees that our paragraph has a text node that changed...
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
Great to hear, thanks Marvin! 🙌
FYI: We’ve shipped the strictly equal vnode optimization earlier this year. I’m unable to reproduce the issue in the linked codesandbox when updating to the latest version of Preact 🎉