Difference between HTML and React Event Handling
In HTML | In ReactJS |
---|---|
we specify event using “onclick”,”onsubmit”which is the normal convention. | We specify the event using “onClick”,”onSubmit” likewise which is camel case convention. |
We bind or provide the listener in form of the string. | We bind or provide the listener in form of function name or method name as a variable. |
The string we pass to the listener should have “( )” at the end in order to work. | We are only suppose to pass the method name and nothing else. React can determine that it has to run this method. |
We can add event listener any time using external javascript. | We have to specify all the Events at the time of creating the component. |
Difference between HTML and React Event Handling
Event handling in HTML and React are different from one another in terms of syntax and some rules. The reason behind this is that React works on the concept of virtual DOM, on the other hand, the HTML has access to the Real DOM all the time. We are going to see how we can add the events in HTML and how React differs in event handling.
Contact Us