Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-05-31 20:13:35 09月14日 Update

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.

Tags: Frame state object property component content data complex one-way two-way reason that is concept view appropriate salient some most meaning meaning. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info MySQL macOS vpn