Here is my component. whenever i call the event it works fine. But page getting refreshed each time. how to prevent this. I understood that i need to add event.preventDefult but adding that shows error. please show me the correct way to do this:
export class Header extends React.Component {
state:NaviState = {
show:false
}
toggle = ():void =>{
console.log("h"); //page getting refreshing each click
this.state = {show:!this.state.show}
}
render() {
return (
<header>
<h1><a className="hidden tantum-logo" href="#">Welocome to Tantum website</a></h1>
<div className="screen"></div>
<nav className="small">
<a className="nav-icon hidden" onClick={this.toggle} href="#">tantum-Menu</a>
</nav>
</header>
)
}
}