when to use react memo code example
Example 1: react memo
function MyComponent(props) {
}
function areEqual(prevProps, nextProps) {
}
export default React.memo(MyComponent, areEqual);
Example 2: how to use react memo hooks
function moviePropsAreEqual(prevMovie, nextMovie) {
return prevMovie.title === nextMovie.title
&& prevMovie.releaseDate === nextMovie.releaseDate;
}
const MemoizedMovie2 = React.memo(Movie, moviePropsAreEqual);
Example 3: how to add react.memo in export list
export const MemoMainPostTopic = React.memo(MainPostTopic);
const MainPostTopic = memo(() => {
...
})
export { MainPostTopic };