Redux Presentational Components Vs Container Component

前端 未结 3 1251
不思量自难忘°
不思量自难忘° 2020-12-01 20:10

I\'m beginner of react development with redux. I\'m wondering what are the Presentational Components and Container Components.

  • How to categorized components a
3条回答
  •  爱一瞬间的悲伤
    2020-12-01 20:19

    This is how I understand it:

    Presentation Components

    concern with how things look

    Container Components

    components with logic involved

    However, upon further research, I realised that such separation is sometimes unnecessary as mentioned by Dan Abramov here: https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0

    You can understand presentation component as something you find in react UI component library. They makes UI component looks pretty. Then, one only have to compose the presentation components in container component as needed.

    Having said that, if you're using a component library, then most of the component you coded will be container component. Of course you can make your own react UI component library.

    As nothing is hard rules in programming, react UI component library may have some logic tightly coupled with the component (ie how it behaves, such as a drawer component) and still treated to be presentation component.

提交回复
热议问题