Javascript – How can React access Hooks functions' local variables?
Below is a simple hook function App() { let [counter, setCounter] = useState(0); return <button onClick={() => setCounter(counter + 1)}>{counter}</button>; } My understanding on how react works is: React will call App() to get a React element as: let element…