-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.0.0-alpha.1 - Component returned from useMemo renders when nothing has changed #1398
Comments
After some testing there doesn't appear to be anything wrong with The first time it provides the result of the callback and as the value doesn't change the next time it provides the same result, which is correct. Not sure what causes the difference in rendering between React and Preact.. Just a wild assumption here, but shouldn't a component be prevented from rendering again when nothing (props / state) has changed? |
Hmm - this seems like it might be mixing up import { memo } from 'preact/compat';
const Foo = ({ a, b }) => <div>{a}{b}</div>;
const MemoizedFoo = memo(Foo); |
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 🎉 |
Great to hear, thanks Marvin! 🙌 |
I was searching for an alternative to
shouldComponentUpdate
when I discovered thatuseMemo
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).
The text was updated successfully, but these errors were encountered: