<button onClick={function() {console.log("Clicked")}}
doesn’t seem to work, however…
<button onClick={() => {console.log("Clicked")}}
works perfectly fine.
Why is this the case? As far as I know, the shorthand is simply syntactic sugar for convenience, and doesn’t actually have any real difference compared to declaring anonymous functions with the function keyword.
There is no reason I can see why the normal function shouldn’t work. Post a live example on Stackblitz.
Not sure what you mean, but if all you have in the HTML is the function definition then clicking the button won’t do anything. It will run the code that defines the function but not actually invoke the function.