Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!