为什么React不被视为MVC? [英] Why isn't React considered MVC?

查看:341
本文介绍了为什么React不被视为MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道ReactJS不被认为是MVC,因为创建者自己已经这么说了.但是,最近,有人问我为什么要使用React,即使它适合MVC模式,也不认为它是MVC. React呈现一个视图,当使用客户端的人进行更改时,React将考虑更改,并根据需要更新状态(不是仅是模型状态?),然后返回更新的视图(就像控制器一样)将).我对MVC架构的严格定义有非常基本的了解,并对为什么React现在不是MVC感到非常困惑.

I know that ReactJS isn't considered MVC, because the creators themselves have said so. But, recently, I was asked WHY React it isn't considered MVC even though it fits the MVC pattern. React renders a view, and when the someone using the client makes changes, React will take into account the change, update a state if needed (and isn't state just the model?), then return the updated view (just like a controller would). I have a very basic understanding of the strict definitions of MVC architecture, and am extremely confused by why React isn't MVC now.

推荐答案

反应既不是MVC,也不是MVC.这是一个渲染视图的库(有很多很酷的东西,但仍然有).您可以使用MVC模式,Flux/Redux或其他任何方式.

React is neither MVC or notMVC. It's a library to render the View (with a lots of cool stuff, but still). You can use either MVC patterns, or Flux/Redux, or whatever.

MVC和Flux之间的区别在于,最新版本实现了单向数据流.因此,您的数据只能向一个方向移动. Action -> Middleware -> Store -> View. MVC是双向的;您可以从View和Controller更改Model.

The difference between MVC and Flux is that latest implements unidirectional data flow. So your data can move only one direction. Action -> Middleware -> Store -> View. MVC is bidirectional; you can change Model from View and from Controller.

这篇关于为什么React不被视为MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆