Redux演示组件与容器组件 [英] Redux Presentational Components Vs Container Component
本文介绍了Redux演示组件与容器组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是减少反应发展的初学者。我想知道什么是演示组件和容器组件。
I'm beginner of react development with reduced. I'm wondering what are the Presentational Components and Container Components.
- 如何将组件分类为演示或容器?
- 这两者有什么区别?
- 以这种方式对组件进行分类有什么好处?
推荐答案
如果将组件分为两类,您会发现组件更容易重复使用和推理。我将它们称为容器和演示组件。
You’ll find your components much easier to reuse and reason about if you divide them into two categories. I call them Container and Presentational components.
我假设你对redux架构有所了解
I assume you have knowledge about redux architecture
容器组件
- 意识到redux
- 订阅redux state
- 发送给redux行动
- 由react-redux生成
- 关注工作原理
- Aware of redux
- Subscribe redux state
- Dispatch to redux actions
- Generated by react-redux
- Focus on how things work
演示组件
- 不知道redux
- 从道具中读取数据
- 在道具上调用回调
- 由开发人员撰写
- 关注事物的外观
- Unaware of redux
- Read data from props
- Invoke callbacks on props
- Written by developer
- Focus on how thing look
分类组件的好处
- 可重用性
- 关注点分离
有关详细信息,请参阅此文章
For more details read this article
这篇关于Redux演示组件与容器组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文