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

184
Visualizações
Accessing HTML element through React and adding onClick effect

I have a React application, which uses GraphQL to fetch data from backend. Requested data is a html code (content with some divs) built with CMS page editor and rendered using React.

HTML code is rendered using https://www.npmjs.com/package/html-react-parser

How can I access <button class="someClass">SUBSCRIBE</button> through different react component ? The reason I want to access it through react is that I have a Newsletter module which is responsible for making GQL requests and validating recaptcha, as well as Popup module. The popup should be displayed when we hit SUBSCRIBE - this is why I want to attach onClick to that button.

Should I use document.getElementsByClassName in componentDidMount ? Or is there a better way to achieve things like this ?

Newsletter box

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