import React, { memo } from 'react';
function MyComponent(props) {
/* render using props */
}
function areEqual(prevProps, nextProps) {
/*
return true if passing nextProps to render would return
the same result as passing prevProps to render,
otherwise return false
*/
}
export default React.memo(MyComponent, areEqual);
0
4
const MyComponent = React.memo(function MyComponent(props) {
/* only rerenders if props change */
});
Thank you!
4
0
Are there any code examples left?
New code examples in category Javascript