Sign in
Log inSign up

Why do you write event.preventDefault() in React?

Default profile photo
Anonymous
·Feb 23, 2018
doMeow = e => {
 e.preventDefault();
 // do meow here
}

render() {
    return(
        <a onClick={this.doMeow} href="/">Meow</a>
    );
}
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2025 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct