Can anyone help me understand how functional cmp gets re-render whenever there is change in state.
refer below e.g.
function App() {
const [count, updateCount] = useState(0);
return (
<div className="App">
<h1>{count}</h1>
<button onClick={() => updateCount(count + 1)}>Update</button>
</div>
);
}
If I compare this with class based react component then over there we had render function inside class which I believe must be getting trigger whenever there is changes in state or props (there must be chain of life-cycle functions and one of them would be this.render())
But with above code structure App is a functional component and inside App we are changing state/count, how react get to know that after updateCount/setter function, App/(or its parent function) should get called again? I mean we are not passing reference of App function to useState right.