DEV Community

Event handling in React vs HTML

Sebastian Davies on February 04, 2024

React and HTML are two technologies used for building user interfaces. There are many differences and similarities between the two. Differences mos...
Collapse
 
brense profile image
Rense Bakker

If you want to do it with html, its better to find the DOM node with JavaScript and attach the event listener with addEventListener, that way you retain code highlighting/completion and type checking on your event handler function call. Plus it allows you to also remove an event listener during runtime with removeEventListener.