conventions.io

Tech Challenge

2026-10-09

⚛️

Daily Tech Challenge

React

medium
Question 1 of 5

useMemo is called here WITHOUT a dependency array. This is a production build with no StrictMode. Report mounts, then the user clicks the button three times (rows never changes). How many times is 'summing' logged in total?

Example
function Report({ rows }) {
  const total = useMemo(() => {
    console.log('summing');
    return rows.reduce((sum, r) => sum + r.amount, 0);
  });
  const [open, setOpen] = useState(false);

  return (
    <button onClick={() => setOpen(!open)}>
      Total: {total} {open ? '-' : '+'}
    </button>
  );
}

Friday, October 9, 2026 · A new challenge drops every day