function ActionLink() {
function handleClick(e) { e.preventDefault(); console.log('The link was clicked.'); }
return (
Click me
);
}
Example 4: react button onclick
import React from 'react';
function App() {
function sayHello() {
alert('Hello!');
}
return (
);
}
export default App;
Example 5: handling event in jsx
//Event hadling in react
function ActionLink() {
function handleClick(e) {
e.preventDefault();
console.log('The link was clicked.');
}
return (
Click me
);
}