MG
In both cases we use this two lines let currCount = countRef.current; setCounter(currCount = > currCount + 1 ); why we use the same name for the function parameter inside the setCounter? setCounter( currCount => currCount + 1); I believed that adding an arrow function inside a setState will make the parameter the last value of the state thus unrelated with the countRef.current, and unrelated with the currCount, which is a local function variable.