GoConqr has a new look! Let us know what you think.

Module 18 of 28 · Media

React events

Kostas Diakogiannis

React events

React events

Events in React can be created through ‘inline-style’. Inside the JSX element that triggers the event. That means that there are many attribute names, one for every event, some of the most common used are:

onClick

onMouseOver

onChange

onSubmit

The pattern is that we type on and the name of the event together, in a camelCase syntax! Then the value can be a javascript expression inside {} curly braces. Most of the times you will call a specific function there. Let’s take a look at the example above.

The button that is rendered from the component has an event attached to it. When clicked, executes the function with the name handleClick, because this function has not been declared globally but inside the class, the this keyword must come before. That indicates that we are talking about a function that is declared inside the same class with the button and not a global function.

But what is this bind function that lies next to it?

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?