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

342
Vistas
Unexpected use of comma operator

I have following error message:

Unexpected use of comma operator no-sequences

This is the code:

<Icon.Clipboard onClick={() => (

    this.handleModal("open","modify"), this.prettyPrint(JSON.stringify(res)))}
/>

Where does the problem come from?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's the , after this.handleModal("open","modify"). That arrow function should use a full function body ({ after the => and its accompanying } at the end) and a statement separator (; or newline) between the two function calls:

<Icon.Clipboard onClick={() => {
    this.handleModal("open","modify");
    return this.prettyPrint(JSON.stringify(res));
}} />

Or more likely, you don't want that return (but that's what your code using the comma operator was doing):

<Icon.Clipboard onClick={() => {
    this.handleModal("open","modify");
    this.prettyPrint(JSON.stringify(res));
}} />

The comma operator evaluates its left-hand operand, then throws that result away, evalutes its right-hand operand, and takes that as its result. It's commonly abused as a statement separator, but it isn't one and doing so can have unintended consequences (such as returning the result of printPrint above — probably harmless in this case, but often not).

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