Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda