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

440
Visualizações
Unexpected use of 'confirm' no-restricted-globals

I am writing code for the delete confirmation for the user, but when I run it up it shows this error enter image description here

This is my code for that

    onDelete = (id) => {
      console.log(id);
      if (confirm('You want to delette ?')) {
       //eslint-disable-line
        this.props.onDelete(id);
      }
    };

Can anyone explain it to me, Please? Although I have to add //eslint-disable-line but it does not work, my problem in here is when I add //eslint-disable-line beside if (confirm('You want to delette ?')) { like this

`if (confirm('You want to delette ?')) {//eslint-disable-line`

but when I save it, it show like this

if (confirm('You want to delette ?')) {
       //eslint-disable-line

, it automatically down the line, so that the reason display error above, I do not know how to turn of the auto down line when I save

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can change this part:

if (confirm('You want to delette ?')) {
       //eslint-disable-line
        this.props.onDelete(id);
      }
    };

to:

if (window.confirm('You want to delette ?')) {
       //eslint-disable-line
        this.props.onDelete(id);
      }
    };

Just add window.

over 4 years ago · Santiago Trujillo Relatório

0

You can disable this error by adding eslint comment above the confirm() method.

onDelete = (id) => {
  console.log(id);
  // eslint-disable-next-line no-restricted-globals
  if (confirm('You want to delete ?')) {
   //eslint-disable-line
    this.props.onDelete(id);
  }
};

or you can replace the confirm method with window.confirm()

onDelete = (id) => {
  console.log(id);
  if (window.confirm('You want to delete ?')) {
   //eslint-disable-line
    this.props.onDelete(id);
  }
};
over 4 years ago · Santiago Trujillo Relatório

0

You have to use window.confirm() instead of just confirm().

over 4 years ago · Santiago Trujillo 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