cf.completefrontend

ConceptMedium

Why should components be pure, and what does Strict Mode's double render catch?

The code
let lineNumber = 0;
 
function CartLine({ name }) {
  lineNumber = lineNumber + 1;
  return (
    <li>
      {lineNumber}. {name}
    </li>
  );
}

The answer

Answer it out loud first, the way you would in the interview. Then compare.

Checking your sign-in…