Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda