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

80
Views
React querySlectorALL not working inside react

Need to get an element of the 2nd item of the array when it's clicked, but in react it won't trigger when clicking on it. In this case, we should use querySlectorALL, how I get this element?

 function App () {
  
  const List = props => {
    const listItems = props.items
    return (
      <ul>
        {listItems.map((item, index) => (
          <li key={index}>{item}</li>
        ))}
      </ul>
    )
  }

  let listItem = document.querySelectorAll('li')[1]
  if (listItem) {
    console.log('sadas')
    listItem.click()
  }

  return (
    <div className='App'>
      <List items={['A', 'B', 'C']} />
    </div>
  )
}
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!