EasyHooks & Closures💻 Output Question

Use of useMemo with Dependencies

💡

Hint

Consider how the calculateArea function is called every time App is called, even if the radius hasn't changed.

What does this output?

function calculateArea(radius) {
  console.log('Calculating area...');
  return Math.PI * radius * radius;
}

function App() {
  const [radius, setRadius] = { radius: 5, setRadius: () => {} };
  const area = calculateArea(radius);
  return area;
}

const area1 = App();
console.log(area1);
const area2 = App();
console.log(area2);

Correct Output

Calculating area...
49.08738521234036
Calculating area...
49.08738521234036

Why this output?

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz