React.memo()
`React.memo()` is a higher-order component (HOC) provided by React. It’s used to memoize the rendering of functional components based on their props. This means that React will re-render the component only if its props have changed since the last render.
Syntax of React.memo():
const MemoizedComponent = React.memo((props) => {
// Component logic here
});
When to use React.memo() over useMemo() & vice-versa ?
React provides us with powerful tools to optimize the performance of our applications. Two such tools are `React.memo()` and `useMemo()`, which serve similar yet distinct purposes.
In this article, we’ll explore when to use `React.memo()` over `useMemo()` and vice versa, along with syntax and code examples to illustrate their usage.
Table of Content
- React.memo()
- useMemo()
- Choosing Between React.memo() and useMemo()
- Example of React.memo() & useMemo