Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the reason why react is not a mvvm framework?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "react is not the reason why mvvm framework is not", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "react is not the reason why mvvm framework is what" article.

Because react is one-way data binding, and the most prominent feature of mvvm is data two-way binding; mvvm framework is to have a vm object to map view, while react has no pure vm object, and there are properties and states, so react is not a mvvm framework.

The operating environment of this tutorial: Windows10 system, react17.0.1 version, Dell G3 computer.

Why react is not a mvvm framework

Mvvm

First of all, figure out what mvvm means. Vm means view mode.

So the mvvm framework needs to have a vm object to map the view.

That is, when the properties of the vm object change, the corresponding view part will be updated accordingly. More classic is knockoutjs, in which the key concept is the view model,compute,view template and so on. Yes, there is actually a lot of its shadow in vue.

React

Then take a look at react, which does not have a pure vm object, it is full of properties and states.

Map the view with properties and states. So what's the difference between attributes and states and vm? Personally, vm objects are treated equally in the end, regardless of whether your values are passed in from the outside or defined internally. In many cases, there is also a two-way binding mechanism, perhaps the early flex, it is amazing, the later mvvm framework has the concept of two-way binding. React, on the other hand, emphasizes the immutability of attributes and unidirectional data flow. Internal state, internal self-control.

Such a design may be more complex in terms of design, but it becomes more definite and clearer in terms of use. If react is familiar with, manage the appropriate state for the appropriate components, and make a reasonable layering of the state, the application complexity will be greatly reduced. Then, redux has a very advanced concept called container components and pure presentation components. If you understand this design idea and concentrate complex things into a small number of components, most components will become pure display components, further reducing application complexity.

One of the most striking features of MVVM: two-way binding.

React does not have this, it is one-way data binding.

React is an one-way data flow library, state-driven view.

State-- > View-- > New State-- > New View above is the content of this article about why react is not the mvvm framework. I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report