You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
In React's shouldComponentUpdate callback, if false is returned, the component will not re-render, even if its parent's props change (i.e. when a parent forces its tree of children to re-render because its own props changed, those children will not render if their shouldComponentUpdate returns false).
After much debugging today, I realized that shouldUpdate not does behave the same way. If the child is re-rendering because its props changed and not because of a parent's props changing (which in turn re-renders its tree), it works fine. But if the child is re-rendering because its parent's props changed (re-rendering the parent's tree of children), it overlooks shouldUpdate and the children re-render despite the return value of shouldUpdate. The same is true for lifecycle's componentShouldUpdate from what I can tell.
I am not sure if onlyUpdateForKeys or onlyUpdateForProps have the same issue.
The text was updated successfully, but these errors were encountered:
I'm having this issue in my work application aswell. I tried to reproduce the issue in a codesandbox but couldn't O.o
I'm using the exact same versions of recompose and react.
This happened to me too and the same behavior happens for onlyUpdateForKeys. I'm using shouldUpdate or onlyUpdateForKeys in an HOC that is a component in another HOC. When the parent HOC updates, the child HOC updates regardless of the return value of shouldUpdate or onlyUpdateForKeys;
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In React's
shouldComponentUpdate
callback, iffalse
is returned, the component will not re-render, even if its parent's props change (i.e. when a parent forces its tree of children to re-render because its own props changed, those children will not render if theirshouldComponentUpdate
returnsfalse
).After much debugging today, I realized that
shouldUpdate
not does behave the same way. If the child is re-rendering because its props changed and not because of a parent's props changing (which in turn re-renders its tree), it works fine. But if the child is re-rendering because its parent's props changed (re-rendering the parent's tree of children), it overlooksshouldUpdate
and the children re-render despite the return value ofshouldUpdate
. The same is true forlifecycle
'scomponentShouldUpdate
from what I can tell.I am not sure if
onlyUpdateForKeys
oronlyUpdateForProps
have the same issue.The text was updated successfully, but these errors were encountered: