how to fire a react class function on click of html tag code example
Example 1: react button onclick
import React from 'react';
function App() {
function sayHello() {
alert('Hello!');
}
return (
<button onClick={sayHello}>
Click me!
</button>
);
}
export default App;
Example 2: react button onclick
<button onClick={sayHello}>Click</button>