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

265
Views
how to deal with DOM walks and while loop related no-loop-func issues in react?

reading a few questions on here, and reading through the docs: I'm still a bit confused about how to fix this warning of no-loop-func:

function scrollHorizontally(e,listOfBannedClasses, parentClass){
    //truncated example
    let target = e.target;
    while(target.parentNode!== null && target.className!==parentClass &&target.parentNode!== undefined){
        if(listOfBannedClasses.some(x=>target.parentNode.classList.contains(x)))
            {
            return;
        }      
        target = target.parentNode;
    
    }
}

I understand that the problem stems from target being defined outside the while loop. but I'm not using a function of any kind to reassign it: it just walks up a node tree. what I am trying to do is to get the highest element of the DOM tree possible that is below a 'banned class' from the element clicked on.

is there a cleaner way of doing that then this code?

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!