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

查看:28
本文介绍了为什么 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.

推荐答案

React 既不是 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 的区别在于,最新实现了单向数据流.因此,您的数据只能向一个方向移动.<代码>动作 ->中间件 ->存储 ->查看.MVC 是双向的;您可以从视图和控制器更改模型.

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天全站免登陆