way to avoid re-renders for an atom with a nested object? #2922
Replies: 1 comment
-
Ah... never mind. CompA and CompB were re-rendering because CompC (a parent component of A and B) were re-rendering. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Say we have an atoms like this.
I have a two separate components; let's say CompA and CompB.
CompA only uses "firstNameAtom" and CompB only uses "legalAgeAtom".
When, CompB sets a new legal age, CompA re-renders even though CompA is not directly referencing the upstream root object (deepObjectAtom).
Is this an expected behavior?
Fortunately, React Compiler automagically fixes this issue but I am wondering if there is a way to prevent re-renders when value of the downstream object remains the same regardless of change in the upstream object without ReactCompiler auto-memo feature.
Beta Was this translation helpful? Give feedback.
All reactions