Home > Article > Web Front-end > What can react do?
react is a JavaScript library, mainly used for building UI, and can be used to build "predictable" and "declarative" Web user interfaces; React can build large-scale applications where data changes over time, and Can improve development efficiency.
React originated as an internal project at Facebook. Because the company was not satisfied with all the JavaScript MVC frameworks on the market, it decided to write its own one for Build an Instagram website. After making it, I found that this set of things is very useful, so it was open sourced in May 2013.
React is a JavaScript library for building user interfaces. React is mainly used to build UI. Many people think of React as the V (view) in MVC. React has high performance and very simple code logic. More and more people have begun to pay attention to and use it.
React can be used to build "predictable" and "declarative" Web user interfaces; React can build large-scale applications where data changes over time, and can improve development efficiency
You can pass various types of parameters in React, such as declaration codes to help you render UI, static HTML DOM elements, dynamic variables, and even interactive application components.
Features of React
Declarative design −React adopts a declarative paradigm, which makes it easy to describe applications.
Efficient −React minimizes interaction with the DOM by simulating the DOM.
Flexible −React works well with known libraries or frameworks.
JSX − JSX is an extension of JavaScript syntax. React development doesn't necessarily use JSX, but we recommend it.
Component − Building components through React makes it easier to reuse code and can be well applied in the development of large projects.
One-way response data flow − React implements one-way response data flow, thereby reducing repeated code, which is why it is simpler than traditional data binding.
The main principles of React
In traditional web applications, DOM operations are usually directly updated, but we know that DOM updates are usually relatively expensive. In order to reduce operations on the DOM as much as possible, React provides a different and powerful way to update the DOM instead of direct DOM operations. It is VirtualDOM, a lightweight virtual DOM, which is an object abstracted by React, describing what the dom should look like and how it should be presented. The real DOM is updated through this Virtual DOM, and this Virtual DOM manages the update of the real DOM.
Why can it be faster through this extra layer of Virtual DOM operations? This is because React has a diff algorithm. Updating VirtualDOM does not guarantee that it will affect the real DOM immediately. React will wait until the event loop ends, and then use this diff algorithm to calculate the minimum step by comparing the current new dom representation with the previous one. Update the real DOM.
The most obvious benefit is React’s so-called dom diff, which can achieve delta-level dom updates. When data changes cause DOM changes, React does not refresh globally, but calculates the differences through its internal dom diff algorithm, and then updates them with the smallest granularity. This is also why React claims to have good performance.
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of What can react do?. For more information, please follow other related articles on the PHP Chinese website!