What is react? What does react mainly do? (Q&A)
This article mainly introduces you to the basic understanding of react. Do you dare to say that you know a lot about react? If not, then take a look at this article
1. Why is Facebook building React?
Facebook engineers are working on large projects , due to their very large code base and large organization, MVC quickly became very complex. Whenever a new function or feature needed to be added, the complexity of the system increased exponentially, causing the code to become fragile. and unpredictable, as a result, their MVC is falling apart, so Facebook believes that MVC is not suitable for large-scale applications. When there are many models and corresponding views in the system, its complexity will expand rapidly, making it very difficult to understand and debug, especially It is the possible two-way data flow between the model and the view.
Based on the above reasons, Facebook believes that MVC cannot meet their expansion needs. In order to solve the above problems, they need to "organize the code in some way to make it more usable." Prediction", so they proposed Flux and React to implement it.
2、 What is React?
##React It 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 to build the 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 for building UI, many people think React is 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.
3. What problem does React solve?
We built React to solve one problem: building large applications with data that changes over time. Build large-scale applications where data changes over time
4. React features
1.Declarative design −React adopts a declarative paradigm, which makes it easy to describe applications.
2.Efficient −React minimizes the interaction with DOM by simulating DOM.
3.Flexible −React works well with known libraries or frameworks.
4.JSX − JSX is Extension of JavaScript syntax. ReactDevelopment does not necessarily use JSX, but we recommend using it.
5.Component − Build components through React, making the code easier to reuse and can be well applied in the development of large projects.
6.One-way response data flow − React implements a one-way response data flow, thereby reducing repeated code, which is why it is simpler than traditional data binding.
5. Main principles of React
Traditional In web applications, DOM operations are generally 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. Through this Virtual DOM updates the real DOM, and this Virtual DOM manages the update of the real DOM. (If you want to learn more, go to the PHP Chinese website React Reference Manual column to learn)
Why can the operation of Virtual DOM be faster through this extra layer? ? 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 the reason why React is said to have good performance.
6. Components Components
is on the DOM tree The nodes are called elements, which is different here. They are called commponents on Virtual DOM. The node of Virtual DOM is a complete abstract component, which is composed of commponents. component is used in It is extremely important in React because the existence of components makes calculating DOM diff more efficient.
7. Application
There are many foreign applications, such as facebook, Yahoo, Reddit, etc. You can see a list of Sites-Using-React on github: https://github.com/facebook/react/wiki/Sites-Using-React. If you are in China, I checked it and there seems to be relatively few. Currently, I know of one from Hangzhou. Search car. Most technologies are generally slow to be applied domestically.
8. Comparative analysis
and some other js Compared with frameworks, such as Backbone, Angular, etc., how does React compare?
1. React is not an MVC framework. It is about building web components that are easy to be called repeatedly. Focus on the UI, that is, the view layer
2. Secondly, React is a one-way rendering from data to view, not two-way data binding
3. Do not directly operate the DOM object, but use the virtual DOM to apply it to the real DOM in the smallest steps through the diff algorithm.
4. It is not convenient to directly operate the DOM. Most of the time you just program the virtual DOM
9. Relationship with React Native
Because the design idea of React is extremely unique, it is a revolutionary innovation and has outstanding performance. The code logic is very simple. Therefore, more and more people are beginning to pay attention to and use it, thinking that it may be the future of the Web Mainstream tools for development.
#The project itself has grown bigger and bigger, from the earliest UI engine to a complete set of front-end and back-end Web App solutions. The derived React Native project has even more ambitious goals and hopes to use it to write Web Apps. way to write Native App. If it can be realized, the entire Internet industry will be subverted, because the same group of people only need to write the UI once and it can run on the server, browser and mobile phone at the same time.
This article ends here (if you want to see more, go to the PHP Chinese websiteReact User ManualLearning in the column), if you have any questions, you can leave a message below.
The above is the detailed content of What is react? What does react mainly do? (Q&A). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to build a real-time chat application using React and WebSocket Introduction: With the rapid development of the Internet, real-time communication has attracted more and more attention. Live chat apps have become an integral part of modern social and work life. This article will introduce how to build a simple real-time chat application using React and WebSocket, and provide specific code examples. 1. Technical preparation Before starting to build a real-time chat application, we need to prepare the following technologies and tools: React: one for building

React front-end and back-end separation guide: How to achieve front-end and back-end decoupling and independent deployment, specific code examples are required In today's web development environment, front-end and back-end separation has become a trend. By separating front-end and back-end code, development work can be made more flexible, efficient, and facilitate team collaboration. This article will introduce how to use React to achieve front-end and back-end separation, thereby achieving the goals of decoupling and independent deployment. First, we need to understand what front-end and back-end separation is. In the traditional web development model, the front-end and back-end are coupled

How to use React and Flask to build simple and easy-to-use web applications Introduction: With the development of the Internet, the needs of web applications are becoming more and more diverse and complex. In order to meet user requirements for ease of use and performance, it is becoming increasingly important to use modern technology stacks to build network applications. React and Flask are two very popular frameworks for front-end and back-end development, and they work well together to build simple and easy-to-use web applications. This article will detail how to leverage React and Flask

React Responsive Design Guide: How to Achieve Adaptive Front-end Layout Effects With the popularity of mobile devices and the increasing user demand for multi-screen experiences, responsive design has become one of the important considerations in modern front-end development. React, as one of the most popular front-end frameworks at present, provides a wealth of tools and components to help developers achieve adaptive layout effects. This article will share some guidelines and tips on implementing responsive design using React, and provide specific code examples for reference. Fle using React

How to build a reliable messaging application with React and RabbitMQ Introduction: Modern applications need to support reliable messaging to achieve features such as real-time updates and data synchronization. React is a popular JavaScript library for building user interfaces, while RabbitMQ is a reliable messaging middleware. This article will introduce how to combine React and RabbitMQ to build a reliable messaging application, and provide specific code examples. RabbitMQ overview:

React code debugging guide: How to quickly locate and resolve front-end bugs Introduction: When developing React applications, you often encounter a variety of bugs that may crash the application or cause incorrect behavior. Therefore, mastering debugging skills is an essential ability for every React developer. This article will introduce some practical techniques for locating and solving front-end bugs, and provide specific code examples to help readers quickly locate and solve bugs in React applications. 1. Selection of debugging tools: In Re

ReactRouter User Guide: How to Implement Front-End Routing Control With the popularity of single-page applications, front-end routing has become an important part that cannot be ignored. As the most popular routing library in the React ecosystem, ReactRouter provides rich functions and easy-to-use APIs, making the implementation of front-end routing very simple and flexible. This article will introduce how to use ReactRouter and provide some specific code examples. To install ReactRouter first, we need

How to use React and Google BigQuery to build fast data analysis applications Introduction: In today's era of information explosion, data analysis has become an indispensable link in various industries. Among them, building fast and efficient data analysis applications has become the goal pursued by many companies and individuals. This article will introduce how to use React and Google BigQuery to build a fast data analysis application, and provide detailed code examples. 1. Overview React is a tool for building
