Member-only story
Optimizing Performance Using React.memo
React.memo is a higher-order component in the React library. Higher-order components take another component as an argument and return a modified version of the component.
In practice, React.memo memoizes a component such that it does not rerender if its props do not change. When used on a component, it makes a shallow comparison of the props it received whenever its parent rerenders. Let’s take a look at a demo I created.
This repo of this demo can be found here:
There are two components here:
App.jsx
function App() {
const [count, setCount] = useState(0)
const [childColor, setChildColor] = useState('#fffaaa') const generateRandomColor = () => {
setChildColor( '#' + Math.floor(Math.random()*16777215).toString(16));
} return (
<div className="App">
<div…










