Optimization with useMemo
Use useMemo to memoize the result of expensive calculations so they don't run on every render unless dependencies change.
React JS 0 to Hero: The Complete Guide
Use useMemo to memoize the result of expensive calculations so they don't run on every render unless dependencies change.