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

345
Visualizações
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 Respostas
Responde à pergunta

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 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