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

193
Visualizações
Is there a way to put a comma between objects without being affected by :hover

i am looking for a way to map over an array and seperating objects by a comma, except for the last one. There are plenty of questions regarding this topic, but i am looking for a solution that doesn't "bind" the comma before the rendered object, like:[About][, Other] Instead of this i am looking for: [About], [Other] since i am using an hover-effect on these objects and dont want the comma to be affected.

I tried these solutions but first one is what i described above

<span key={index} className="filter-tag">{ (index ? ', ' : '') + tag }</span>

and the second one doesnt do anything – strangely:

  .filter-tag + .filter-tag::before {
    display: inline-block;
    white-space: pre;
    content: ", ";
  }

Has somebody another possibility for me, since i think there must be a pretty simple solution to this? Thanks in regard for an help!

Edit: I would already be happy, if the comma can be glued to be after the object like [About, ]

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

have you tried this?

EDITED with Anthony's comment

const arrayOfTags = [];


arrayOfTags.map((tag, index) => {
  return <span key={index}>{tag}{`${index === arrayOfTags.length - 1 ? '' : ', '}`}</span>
});

when your iterated index is equals to length of array, doesnt put any comma

you dont need to use css pseudo elements with this solution

about 4 years ago · Juan Pablo Isaza Relatório
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