I\'ve been reading these links:
https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-shouldcomponentupdate
https://reactjs.org/blog/2018/10/23/react-v-16-6.htm
Also you can use in export statement like:
export default memo(Modal, (prevState, nextState) => prevState.show === nextState.show) ;
Here is the documentation for React.memo
You can pass a function to control the comparison :
const Modal = React.memo(
props => {...},
(prevProps, nextProps) => prevProps.show === nextProps.show
);
when the function returns true
, the component will not be re-rendered