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

337
Visualizações
¿Qué debo usar en lugar de 'esto' dentro de la función anidada o puedo usarlo?

Tengo una clase en js: cómo puedo modificar el cuerpo en una función anidada en la línea n. ° 4. Estoy recibiendo una advertencia del IDE:

Potentially invalid reference access to a class field via 'this.' of a nested function

¿Hay alguna solución para escribir esto correctamente? ¿O puedo usar this función anidada dentro?

 fetchStickyAppointment = flow(function* () { fetch(/api/) .then(response => response.json()) .then(data => { if (+data?.id > 0) { this.stickyAppointment = this.currentAppointment = data; } else { this.stickyAppointment = data; this.currentAppointment = this.findCurrentAppointment(); } }); })
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Puede asignar this a una variable fuera del alcance de la función y luego usar eso.

 let self = this; fetchStickyAppointment = flow(function* () { fetch(/api/) .then(response => response.json()) .then(data => { if (+data?.id > 0) { self.stickyAppointment = self.currentAppointment = data; } else { self.stickyAppointment = data; self.currentAppointment = self.findCurrentAppointment(); } }); })
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