Answer the question
In order to leave comments, you need to log in
Can containers contain classes and markup?
Friends,
Components in React are divided into several main groups (write where I'm wrong):
a. Presentative (know how to display data, but don't know the data itself; work only through properties; always pure components)
b. Containers (know what data to display but don't control display; are a composition of presentational components or other containers)
Now look. We have an application markup component (header, menu, footer, etc.).
If we want the hat to be gray, where should we write this style? In the header component, and thereby add display properties to the container? ...or do we make three components, LayoutContainer -> HeaderContainer -> HeaderView, and the latter knows the entire display, and we compose the data and the composition of the header in the HeaderContainer?
At the level of convenience, I prefer the third option. This is more reusable, even though it creates quite a few wrappers. We will then be able to make N-caps for every taste and color only by creating new containers.
Answer the question
In order to leave comments, you need to log in
Components in React are divided into several main groups (write where I'm wrong):
a. Presentative (know how to display data, but don't know the data itself; work only through properties; always pure components)
Where does infa come from that these are always pure components?
If the project is large, then yes, you can create a wireframe with layout and set basic styles in it. If the project will not scale, for example, a simple ToDoshka, then you can set styles in the header component itself.
When you get down to business, you yourself will understand what will be more convenient. And you will redo your components many more times, but in the end you will figure it out
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question