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

131
Views
What is the right way of adding own JS to a React App?

I have just recently started playing around in React and I now want to add own JS for an JS accordion.

const accordionItemHeaders = 
document.querySelectorAll(".accordion_item_title");

accordionItemHeaders.forEach(accordionItemHeader => {
 accordionItemHeader.addEventListener("click", event => {
  accordionItemHeader.classList.toggle("active");
   });
    });

For testing purposes, I have tried inserting the constant right into a jsx container file. It works on and off after saving the edit in VS Code, but stops eventually. Plus, I have two accordions next to each other (same classNames...) and when the script does work, it does only work with one.

This is probably very basic, but I would very much appreciate an answer as I am a complete noob at this point.

Thanks!

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!