We have a counter that is supposed to increment 3 seconds after a button is clicked. However, if the user clicks the button multiple times rapidly, the counter only increases by one (or behaves inconsistently).
Your Task: Fix the code so that every click is accounted for and the final value is always accurate, while ensuring we don't trigger unnecessary intermediate re-renders for every single background calculation.