is React.memo necessary if we do not want to render child component? #602
-
For example, there is a proxy object like: const testStore = proxy({ a: 1 }); and there are two components, one parent and one child: const Child = () => {
return <>child</>;
};
const Parent = () => {
const testSnap = useSnapshot(testStore);
return (
<>
<Button
onClick={() => {
++testStore.a;
}}
>
{`testStore.a: ${testSnap.a}`}
</Button>
<Child/>
</>
)
} When I click the button to update Thx!!! |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Dec 13, 2022
Replies: 1 comment 1 reply
-
Yes, but be careful not to pass snap objects to child component props. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Rongjianying
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, but be careful not to pass snap objects to child component props.