Answer the question
In order to leave comments, you need to log in
How to correctly build the "composition" of components in the application?
The application has 2 levels of users, a regular user and an admin. You need to make a header component in which some information will be the same for everyone, and some - only for admins.
There is a basic header component:
<div class="user-header>
<img src="logo">
<div class="user-header__links>"
...
</div>
</div>
<UserHeader links={some additional links for admins}>
<AdminDropdown/>
</UserHeader/>
Answer the question
In order to leave comments, you need to log in
Option 1 is not very good, why make up two components if you can get by with one.
2 why something to figure out again with a new component.
3 yes, a good option, I made everything up and, depending on the state, for example, made a check if {state && (<>content>)}
3 option is the most advantageous because you don’t need extra components, you immediately show what you need. Although in some cases, for example, if the check is whether the user is authorized, then you can display different components as in the first case, where the first component is the authorization navigation, and the second is the personal account navigation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question