React.useMemo is re-rendering all items in array
I have a react component that stores a set of fruits in useState. I have a memoized function (visibleFruits) that filters fruits. I map visibleFruits to the dom.
I have a react component that stores a set of fruits in useState. I have a memoized function (visibleFruits) that filters fruits. I map visibleFruits to the dom.
I’m getting markers when location is entered by the user, and the markers list is then provided to the Google Maps component. Since I don’t want the map to re-render everytime, I have memoized it. It only re-renders when the markers props changes. But when markers changes, I get the following warning:
Outside of the counter example seen in many YouTube tutorial videos, what are practical/real-world use cases for useMemo
and useCallback
?
Is there a way to use this hook or some its analogue of the React API in the case of a class component?