What exactly is the difference between
onclick="myFunction()"
and
In normal JS - document.getElementById("demo").addEventListener("click", myFunction);
In React - onClick={onClickFunction}>
In the first one, we are calling the function. But in the second one, we are passing the function as a reference.
So when we pass the function reference, how does the function gets called when the click event happens?
Both works exactly as expected. But I would like to understand the underlying concept.