79546505

Date: 2025-03-31 14:35:25
Score: 1.5
Natty:
Report link

In React, when state updates, the component re-renders.

Since the function component runs again from the top, all const variables inside it get reinitialised.

const means you can’t reassign the variable within the same render, but React doesn’t mutate it directly.

Instead, React remembers state between renders and assigns the new value when the component re-renders.

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: vatsa