Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda