4 ms·
> “Also, memo() compares individual prop values, while useMemo() can only look at the whole props object” Passing “Object.values(childProps)” as the dependency
by pavlov 3y ago
> “Also, memo() compares individual prop values, while useMemo() can only look at the whole props object”
Passing “Object.values(childProps)” as the dependency array for useMemo should do the same thing.
But yeah, there are good reasons to use React.memo for convenience with props. It’s not fundamentally different though, and you can definitely useMemo() for caching components when more convenient.
- culi 3y agoUsing `useMemo` without using `React.memo` on the child component does not prevent a rerender at all.