官术网_书友最值得收藏!

Container component

The container component pattern was introduced a long time ago and was popularized within the React community by Dan Abramov. So far, we have created one container component when we refactored the contents of the App component to become a presentational component. It turns out that the App component became a container component—it contains the HelloBox component and implements the necessary logic for it. What did we gain from this approach?  We gained the following:

  • We can implement expanding and collapsing in a different way and reuse the markup of the HelloBox component
  • HelloBox does not contain logic
  • The container component encapsulates logic and hides it from the other components
I highly recommend reading Dan Abramov's medium post on this. Check out  https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0 for more information. Container components are very useful tools when it comes to dependency injection patterns. Have a look at Chapter 10, Managing Dependencies, to learn more.
主站蜘蛛池模板: 平远县| 建水县| 壤塘县| 阿克陶县| 思南县| 盈江县| 临沭县| 鄂托克前旗| 曲沃县| 黑水县| 时尚| 普兰店市| 祥云县| 格尔木市| 合山市| 伊春市| 武穴市| 澄城县| 两当县| 肥乡县| 濮阳市| 革吉县| 永康市| 博野县| 东至县| 肃宁县| 阳原县| 宁晋县| 阿拉善盟| 潍坊市| 莱西市| 崇明县| 当涂县| 乌审旗| 井冈山市| 南陵县| 门源| 丰台区| 卓资县| 贵州省| 扎赉特旗|