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.

10.0.0-alpha.1 - Component returned from useMemo renders when nothing has changed

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vaneenigecommented, Aug 11, 2020

Great to hear, thanks Marvin! 🙌

1reaction
marvinhagemeistercommented, Aug 11, 2020

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 🎉

Read more comments on GitHub >

github_iconTop 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 >

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