React's own characteristics

1. Declarative development
Imperative development: When writing code with native js and jq, most of the code is operating dom. This development model is imperative development.
Declarative development: React is data-oriented programming. You don't need to directly control dom. You only need to manipulate the data, and React will help you operate dom by itself, which can save a lot of code for operating dom. This is declarative development.
2. It can coexist with other frameworks
. The dom controlled by react is the dom whose id is root. Other dom elements on the page can use other frameworks such as jq on your page. So react can coexist with other frameworks.
3. Componentization
When we wrote todo-list, we already used react components. Create a component by inheriting React's Component.
4. One-way data flow
React is a one-way data flow. The data passed by the parent component to the child component can be used by the child component, but it cannot be modified directly through this.props. Otherwise, an error will be reported. (Cannot assign to read only property'xxx' of object'#object')
To pass the value of the child component to the parent component, or to modify the code of the parent component, all must be implemented through the method passed by the parent component.
The advantage of this is that the data is clear and the code is easy to maintain. If each child component can directly modify the data of the parent component, it is troublesome to maintain the code when the child component hides.
5. React is the view layer framework.
Combined with the one-way data flow mentioned above, if it is a large project with a lot of sub-components, to modify a common parameter, it requires many layers of transmission to complete a data change.
React alone is not enough to do large-scale projects. Its advantage lies in the rendering of the view layer, which involves complex data transfer, and needs to be combined with other data layer framework development. Such as mox-box, redux.
6. Functional programming
Most of the react projects are functions, and even the html is implemented by the render function.
His advantage is that it is convenient for code maintenance, and complex functions can be split into multiple functions.
It is also very convenient to automate the test in the front-end. You only need to give the function a parameter and look at its output.
7. The relationship between Props, State and Render function.
Why does the view change when the data changes?
The react view is rendered through the Render function. In the component, if the Props or State changes, the Render function will be executed again.
The Render of the parent component is re-executed, and the Render in the corresponding child component will also be re-executed.

Guess you like

Origin blog.csdn.net/Slueia/article/details/113843005
own