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

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.
主站蜘蛛池模板: 东光县| 临武县| 体育| 亚东县| 海宁市| 兴宁市| 南投市| 太仆寺旗| 尉犁县| 塔城市| 定襄县| 江西省| 黄冈市| 师宗县| 靖西县| 都兰县| 湄潭县| 仪陇县| 襄城县| 延寿县| 安达市| 双辽市| 五原县| 托克逊县| 旬邑县| 凭祥市| 新疆| 巴东县| 长治县| 雷山县| 德兴市| 汽车| 麻城市| 通山县| 盐池县| 五原县| 东兰县| 梓潼县| 临汾市| 利川市| 巫山县|