function sayHello(e) {
e.preventDefault();
alert("hello");
}
---------------------
<a href="#" onclick="sayHello(event);">Click to say Hello</a>
<a href="#" onclick="event.preventDefault(); myfunc({a:1, b:2});" />click</a>
const handleClick = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
event.stopPropagation()
console.log('Clicked')
}
return (
<button onClick={handleClick}>
Button text
</button>
)