(REACT) Should I compose only the repeating tags?

Asked

Viewed 21 times

-2

As the title itself says: Should I compose only the repeating items? an example:

<navbar>
  <a href="LINK">
    <img src="imagem.jpg" alt="Minha Figura" />
  </a>
  <ul>
    <li>Menu1</li>
    <li>Menu2</li>
    <li>Menu3</li>
    <li>Menu4</li>
    <li>Menu5</li>
  </ul>
</navbar>

In the above example, when considering that it is a single page and the menus are anchors I compose the navbar, a, ul and li. is correct?

  • A component is not an HTML element. Search Google and Youtube for different people talking about componentization so you know and decide what you need. Becomes opinion-based, since you will hardly find two people componentizing a page in the same way

1 answer

-1

You can create a component for the <Menu/> as a whole and then you can create a component for the <li> repeating. Or, if you want to make a simpler solution, just create a function to generate these <li> inside the Menu component. But you don’t need more components than that. I hope I understand your question correctly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.