DEV Community

Discussion on: Understand how to Memoize a JavaScript function

Collapse
nickfazzpdx profile image
Nicholas Fazzolari

What would be a potential context/use case for this optimization in the wild?

Collapse
mattdevio profile image
Matt G

Keeping redux selectors from re-rendering

Collapse
dhilipkmr profile image
Dhilip kumar Author • Edited on

The summation function here is so simple. But consider you are making an expensive operation instead of just sum.In that case if you already have a cached value from previous call it becomes handy.

Even react.memo should be doing something similar to this(But handling all limitations which my solution had)