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

96
Visualizações
Get the `value` or `textContent` of element when using arrow function binding REACT

I am asking this question out of curiosity. I want to get the value of an element that fires an event in REACT when I bind the event handler using the arrow function in es6 Class-Based Component

//event handler function
clickHandler() {
  console.log(this.textContent);
}

//the JSX Component element
<div className="first-row d-flex">
   <button
     className="button flex-child"
     data-id="AC"
     type="button"
     onClick={() => this.clickHandler()}>
        someText
    </button>
 </div>

I intend to get its value or textContent like, in the case below, using this bind to the event handler.

//event handler function
clickHandler() {
  console.log(this.textContent);
}

//the JSX Component element
<div className="first-row d-flex">
   <button
     className="button flex-child"
     data-id="AC"
     type="button"
     onClick={this.clickHandler.bind(this)}>
        someText
    </button>
 </div>

Is there a way to do this??

about 4 years ago · Juan Pablo Isaza
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