Home Web Front-end JS Tutorial What is react? What does react mainly do? (Q&A)

What is react? What does react mainly do? (Q&A)

Sep 11, 2018 pm 02:07 PM
react

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.ComponentBuild 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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to build a real-time chat app with React and WebSocket How to build a real-time chat app with React and WebSocket Sep 26, 2023 pm 07:46 PM

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

Guide to React front-end and back-end separation: How to achieve decoupling and independent deployment of front-end and back-end Guide to React front-end and back-end separation: How to achieve decoupling and independent deployment of front-end and back-end Sep 28, 2023 am 10:48 AM

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 build simple and easy-to-use web applications with React and Flask How to build simple and easy-to-use web applications with React and Flask Sep 27, 2023 am 11:09 AM

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

How to build a reliable messaging app with React and RabbitMQ How to build a reliable messaging app with React and RabbitMQ Sep 28, 2023 pm 08:24 PM

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 Router User Guide: How to implement front-end routing control React Router User Guide: How to implement front-end routing control Sep 29, 2023 pm 05:45 PM

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 build real-time data processing applications using React and Apache Kafka How to build real-time data processing applications using React and Apache Kafka Sep 27, 2023 pm 02:25 PM

How to use React and Apache Kafka to build real-time data processing applications Introduction: With the rise of big data and real-time data processing, building real-time data processing applications has become the pursuit of many developers. The combination of React, a popular front-end framework, and Apache Kafka, a high-performance distributed messaging system, can help us build real-time data processing applications. This article will introduce how to use React and Apache Kafka to build real-time data processing applications, and

PHP, Vue and React: How to choose the most suitable front-end framework? PHP, Vue and React: How to choose the most suitable front-end framework? Mar 15, 2024 pm 05:48 PM

PHP, Vue and React: How to choose the most suitable front-end framework? With the continuous development of Internet technology, front-end frameworks play a vital role in Web development. PHP, Vue and React are three representative front-end frameworks, each with its own unique characteristics and advantages. When choosing which front-end framework to use, developers need to make an informed decision based on project needs, team skills, and personal preferences. This article will compare the characteristics and uses of the three front-end frameworks PHP, Vue and React.

Integration of Java framework and front-end React framework Integration of Java framework and front-end React framework Jun 01, 2024 pm 03:16 PM

Integration of Java framework and React framework: Steps: Set up the back-end Java framework. Create project structure. Configure build tools. Create React applications. Write REST API endpoints. Configure the communication mechanism. Practical case (SpringBoot+React): Java code: Define RESTfulAPI controller. React code: Get and display the data returned by the API.

See all articles