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

157
Visualizações
Why is my page blinking even if I set interval to be cleared?

I have set code to change transform property in React. Initially, it is set to --scaleX as 1, then after 6 seconds first setTimeout change it in 0 and 6 seconds after (meaning 12 second from start) setInterval activates and runs every 12 seconds, doing also a change of that style every 6 seconds (total setInterval duration is 12 seconds). A sample of the code is shown below.

useEffect(() => {
   setTimeout(() => {
      redRef.current.style.setProperty("--scale", "scaleX(0)");
    }, 6000);

    let repeatSec = setInterval(() => {
      redRef.current.style.setProperty("--scale", "scaleX(1)");

      setTimeout(() => {
        redRef.current.style.setProperty("--scale", "scaleX(0)");
      }, 6000);
    }, 12000);

    return () => {
      clearInterval(repeatSec);
    };
  }, []);

But, even though I have cleared the interval, the page works and the style changes every 6 seconds, but the page is constantly blinking on strange way. For example, suddenly everything disappears and becomes white, but it returns when I scroll up/down.

Also, flickering occurs in some places at whole the site.

Why is that happening and what should I correct here to prevent it?

about 4 years ago · Santiago Gelvez
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