useMemo shouldComponentUpdate - florypaul/ReactJS GitHub Wiki

https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-shouldcomponentupdate

In a comment above Gabriele Petrioli links to the React.memo documentation that explains how to implement shouldComponentUpdate. I was googling combinations of shouldComponentUpdate + useEffect + "react hooks", and this came up as the result. So after solving my problem with the linked documentation I thought I would bring the information here as well.

This is the old way of implementing shouldComponentUpdate:

class MyComponent extends React.Component{ shouldComponentUpdate(nextProps){ return nextProps.value !== this.props.value; } render(){ return (

{"My Component " + this.props.value}
);
} } The New React Hooks way:

React.memo(function MyComponent (props) {

return

{ "My Component " + props.value }
;

}) I know you were probably asking for more in your question, but for anyone coming from Google looking for how to implement shouldComponentUpdate using React Hooks,

⚠️ **GitHub.com Fallback** ⚠️