1. React is an open source library developed and maintained by the developers of Facebook, Instagram and also a larger community of contributors.
2. A declarative, efficient, and flexible JavaScript library for building user interfaces.
3. Makes developing a large scale, single-page application easier.
4. Supports all the syntax of ECMAScript 2015/ES6.
5. Can perform client-side as well as server-side rendering.
For dynamic UI, DOM was never an optimized solution. Let's take an example of displaying a list containing 10 items and one is getting updated. To reflect the update, DOM will rebuild the entire list making it work 10 times more than what is necessary. This inefficiency can be overcome using Virtual DOM.
Virtual DOM (Document Object Model) is an abstract, lightweight copy of DOM. It can be changed as and when we want and then can be saved to the real DOM. Whenever a change occurs, Virtual DOM efficiently rerenders the DOM. It is much faster than DOM.
Virtual DOM has the same properties as a real DOM object.
React postulated the idea of Virtual DOM. It is commonly used by PayPal, Apple and Facebook.
Reading and writing is really slow in DOM.
Changing the whole DOM each time when there is an update will slow down the page.
Has rapid DOM rendering speed because manipulating the virtual DOM is much faster, because nothing gets drawn on screen.
Only the required part of DOM is updated.
1. React is faster and better, because of Virtual DOM.
2. React can be used on both Client side and server side.
3. For apps having dynamic data, you can go with client side scripting.
4. Static pages can be rendered using server side scripts.
5. Mixture of both helps in maintaining the page safe and efficient.
6. Helps to maintain the readability of apps using components.
7. Can easily update the state by referring the components.
A typical ReactJS program contains:
Components
Elements
Props
States
Functions
Components: Easier to maintain larger apps.
JSX: Optional feature of React that is a JavaScript syntax extension.
Frontend: React only covers the view layer of the app, so you still need to choose other technologies to get a complete tooling set for development.
Inline template: React is using inline templating and JSX that might be awkward to some developers.
JSX is an inline markup that looks like HTML that gets transformed to JavaScript by preprocessors. It is not mandatory to use JSX with React. But React would be elegant if JSX is used.
It starts with a HTML like open tag, and ends with the corresponding closing tag.
const element = <h1>Hello, world!</h1>;
The syntax is intended to be used by preprocessors such as Babel to transform HTML like text into standard JavaScript objects.
React is an open source library developed and maintained by the developers of Facebook, Instagram and also a larger community of contributors. Virtual DOM (Document Object Model) is an abstract, lightweight copy of DOM. JSX is an inline markup that looks like HTML.