Redux/React和MVC,OOP [英] Redux/React and MVC, OOP
问题描述
是否可以将React/Redux视为一个MVC框架,其中也包含了核心的面向对象原则?根据我的经验,我们有一个胖模型(全局state/store
)和瘦控制器(actions creators
),它们按正确的方向(Reducers
中使用的action types
)dispatch
进行某些操作以创建新的状态对象,并充实我们的观点(反应).
Can React/Redux be thought of as an MVC framework in which also captures core Object Oriented principles? From my experience we have a fat model (the global state/store
) and skinny controllers (actions creators
) which dispatch
certain actions in the right direction (action types
used in Reducers
) to create the new state object and hydrate our views (React).
我认为React通过components
和子组件包含抽象,通过扩展Component类编写自己的继承/多态性.而且,我感觉containers
启用了一种封装感,可以隐藏/显示与组件之间的某些redux功能.
I think React encompasses abstraction through components
and subcomponents, inheritance/polymorphism by extending the Component class to write your own. And I feel as if containers
enable a sense of encapsulation which hide/show certain redux functionality to/from the components.
这就是我想到Redux/React架构的方式,但不确定这是正确的.我是否缺少任何要点或区别?
This is how I've come to think of Redux/React architecture but am not sure this is right. Am I missing any key points or distinctions?
推荐答案
为什么需要OOP原则? Redux和React-redux库是关于函数式编程的.首先观看此视频- https://vimeo.com/69255635 ,然后从Redux的作者那里获得免费的在线课程- https://egghead.io/lessons/javascript-redux-唯一不可变状态树
Why do you need OOP principles? Redux and React-redux libraries are about functional programming. Take a look at this video first - https://vimeo.com/69255635, then free online course from Redux's author - https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree
这篇关于Redux/React和MVC,OOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!