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

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.
主站蜘蛛池模板: 临沭县| 安宁市| 陆川县| 喀喇| 凤冈县| 贵州省| 漳浦县| 松桃| 盘山县| 渭源县| 宜城市| 青河县| 章丘市| 谢通门县| 乳山市| 汉阴县| 铜山县| 大英县| 黔南| 江都市| 钦州市| 车险| 舞阳县| 新巴尔虎左旗| 景宁| 元氏县| 任丘市| 江阴市| 铜陵市| 柘城县| 岳阳市| 沅江市| 蕲春县| 衡阳市| 清镇市| 延川县| 保靖县| 尤溪县| 泸水县| 宜昌市| 翁牛特旗|