What is Events React JS?

Events in react js are similar to HTML events. Events are any user action that handles any type of functionalities. For example, in windows 10, double clicking opens the application or a file.

Events in react js are of many types like mouseover, click, double click, drag, drop etc.

In react js we use camelCase representation to define any type of event. For example in HTML, we use onchange=”” but in react js we use it as onChange=””.

Example :-

Events

Note : We didn’t use the parenthesis in onClick={toggleColor} as we don’t want to execute it, we just passed the reference.

If we want to pass the arguments, if any event occurs then we have to use the arrow function.

onClick={ (val) => func(val) }

Leave a Reply

Your email address will not be published. Required fields are marked *