What is React JS?

Share

React JS is an open-source JavaScript library for building user interfaces – usually for single-page and mobile applications.

A user interface in React is built around components. Each of these components is a Javascript function defined by the user.

These components optionally accept inputs, i.e. props (properties), and return React elements that describe exactly how a section of the UI (user interface) should appear accordingly.

React applications are usually built around a single HTML element, often called the root node.

svg viewer

Since React elements are immutable (cannot be changed), the only way to “change” an element is to render a new one on the screen. React maintains a Virtual DOM which records all these element changes.

Elements are rendered on the screen by calling the ReactDOM.render() method which compares the real and virtual DOM elements, making as few changes as possible. The ReactDOM always attemps to avoid reloading the whole page in this diffing process, as shown below:

svg viewer
Copyright ©2024 Educative, Inc. All rights reserved