use memo é react code example
Example: import React, { memo } from 'react';
const MyComponent = React.memo(function MyComponent(props) {
/* only rerenders if props change */
});
const MyComponent = React.memo(function MyComponent(props) {
/* only rerenders if props change */
});