- Hands-On Design Patterns with React Native
- Mateusz Grzesiukiewicz
- 164字
- 2021-08-13 15:12:57
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.
推薦閱讀
- 樂高機(jī)器人設(shè)計(jì)技巧:EV3結(jié)構(gòu)設(shè)計(jì)與編程指導(dǎo)
- FFmpeg入門詳解:音視頻原理及應(yīng)用
- C程序設(shè)計(jì)案例教程
- Drupal 8 Configuration Management
- Node Cookbook(Second Edition)
- Internet of Things with ESP8266
- 深入理解BootLoader
- Node.js區(qū)塊鏈開發(fā)
- Advanced Python Programming
- Mastering Android Studio 3
- Selenium WebDriver Practical Guide
- Microsoft HoloLens By Example
- C Primer Plus(第6版)中文版【最新修訂版】
- jQuery基礎(chǔ)教程(第4版)
- Mastering Assembly Programming