What is the difference between useMemo and React.memo? in which case the React.memo is used? and in which case the useMemo will be used? i have googled for a perfect example to show when the react.memo is used but i cant able to find
What is the difference between useMemo and React.memo? in which case the React.memo is used? and in which case the useMemo will be used? i have googled for a perfect example to show when the react.memo is used but i cant able to find
2
Answers
Both
useMemo
andReact.memo
are used for performance optimization in React applications, but they serve different purposes and are used in different scenarios.useMemo
According to official docs:
You can find its usage here.
React.memo
You can find its usage here.
Summary
Ultimately,
useMemo
is intended for memoizing values, whereasReact.memo
is designed for memoizing components.For more detailed examples, refer to the React official documentation.
React.memo:
useMemo: