Does useMemo have any effect on keyed components?

544 Views Asked by At

When working with a dynamic number of components, React asks developers to provide a unique key, lest this error is thrown:

Each child in a list should have a unique "key" prop

Say that each child shows a different icon and label based upon some prop. Does the usage of useMemo here have any impact on performance?

1

There are 1 best solutions below

4
On

"useMemo will only recompute the memoized value when one of the dependencies has changed." - from React docs

Given that the elements dependencies (state, props) are still the same and nothing has changed the performance benefit should not be negated.