Handling events in React

Now that have seen how to create stateless and stateful React components , we are going to see how to handle DOM events with a class-based component. You can handle events with React in a similar fashion as with DOM elements with some minor differences. With JSX, you will have to use properties using the camel-case version of the name of the event that you want to handle. On top of that, you won’t...

First React component

After a first part where we have seen how to get move from vanilla JavaScript to React, let’s see how we can create real React components. In order to introduce some dynamicity in our React code, we would like to execute functions to compute some JSX instead of relying only on static JSX code. We are lucky since React.createElement can take not only the name of a standard element (like div or h1 )...

From Vanilla JavaScript to React

React is a JavaScript framework used to build user interfaces. It can be used to create JavaScript applications by manipulating dynamically the content of the page. The browser already provides an API to create elements in the page, the DOM, so newcomers may wonder what does React bring to the table and how it relates to the DOM. Vanilla JavaScript and the DOM In JavaScript, just like in most prog...