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

131
Visualizações
function is not defined when im trying to call a function inside my onsubmit function

i have this form say

<form onSubmit={this.formSubmit} id="userForm" name="myForm" noValidate>

im trying to call another function inside my formsubmit() function but it says the function is not defined . what could the reason be

   formSubmit=(e)=>{
    e.preventDefault();
    validateForm();
  }
  validateForm=()=>{
    console.log("test")
  }
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You need to call this.validateForm(). validateForm is bound to the component instance.

about 4 years ago · Juan Pablo Isaza Relatório

0

formSubmit and validateForm are methods of your (component) class, not an independent function. In order to call the inside of the class, you need to call it through the this keyword as it is bound to the class.

about 4 years ago · Juan Pablo Isaza Relatório

0

You are using this key word in the Component it seems. this key word has varying scope depending on where you are using it.

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