airair
All questions

How many renders: memo with an inline object

NewQuizReactmedium~3 minReact.memo, referential equality, render count
const Child = React.memo(function Child({ style }: { style: object }) {
  console.log("child render");
  return <div style={style} />;
});

function Parent() {
  const [count, setCount] = useState(0);
  return (
    <>
      <button onClick={() => setCount(count + 1)}>+1</button>
      <Child style={{ color: "red" }} />
    </>
  );
}

After mounting and clicking +1 three times, how many times has "child render" been logged?

Choose one answer