You will find that your components are much easier to reuse and discuss if you divide them into two categories. I call them Smart (Smart) and Stupid (Dumb), but I also heard Fat and Skinny, Stateful and Pure, Screens and Components and so on. All this is not absolutely the same but the idea is similar. ')
My stupid components:
do not depend on the rest of the application, for example Flux actions or stores
often contained in this.props.children
receive data and callbacks exclusively through props
have your css file
occasionally have their own state
may use other stupid components
examples: Page, Sidebar, Story, UserInfo, List
My smart components:
wraps one or more stupid or smart components
stores the state of the store and forwards it as objects to stupid components
causes Flux actions and provides them with stupid components in the form of callbacks
never have their own styles
rarely give DOM themselves, use stupid layout components.
I put them in different folders to make their distinction clear.
Profit from this approach
The best division of responsibility. You understand your application and your UI better if you write components in this way.
The best reuseability. You can use the same stupid component with completely different sources of wealth.
Stupid components are in fact the “palette” of your application, you can put them all on one page and let the designer customize them by getting into the application logic. You can run regression testing on such a page.
This forces you to extract “component layouts”, such as Sidebar, Page, ContextMenu, and use this.props.children instead of duplicating the same typesetting in various smart components.
Remember, components should not issue a DOM. They should only provide boundaries between UIs.