Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
Adding subitems to table without using React Fragments

I'm currently developing an application which uses old version of React, and it does not yet include Fragments. For now, I won't be able to upgrade version of React.

In the application, I'm currently doing modifications to a table where the use of Fragments would be great. I added nested map which goes through subitems and adds them to the table. Here is how it would probably work if Fragments were an option:

  <tbody>
{expenses.budgetedAmounts
.sort((a, b) => {
  return a.department < b.department;
})
.map((item, index) => (
 <React.Fragment>
 <tr
    key={index}
  >
    <td>
      {item.name}
    </td>

    <td>
      {item.budgetedExpense}
    </td>

    <td>
      {item.actualExpense} 
    </td>

    <td>
      {item.percentageUsed} 
    </td>

    <td>
      {item.availableExpense}
    </td>
  </tr>
  {item.nestedItems.map((nested, secondIndex) =>   
  <tr>
    <td> {nested.name}</td>  
    <td> {nested.price} </td>
  </tr>)}
  </React.Fragment>
))}

JSX expressions must have one parent element, hence the use of Fragment would be nice. Is there a way to do this easily without using Fragments and messing up the table structure?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda