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

84
Visualizações
react loading animation frame stuck

I have a function which takes about 50s to return a value, so I've tried to use a loading spinner while waiting. Below is App.jsx

import { ThreeDots } from "react-loader-spinner";

const [isLoaded, setLoaded] = useState(false);

const LoadingIndicator = (props) => {
    return (isLoaded && (
          <ThreeDots color="#2BAD60" height="100" width="100" />
      )
    );
  };

return (
    <>
      <LoadingIndicator />    
      <UploadForm setLoaded={setLoaded} />    
      <Results isLoaded={isLoaded} setLoaded={setLoaded} />
    </>
  );

Now, the calculation happens within Results component, where I use

useEffect(() => {
  let active = true
  load()
  return () => { active = false }
        
  async function load() {
    setCalculation(undefined) // this is optional
    const res = await longCalcFunc(r, s)
    if (!active) { return }
    setCalculation(res)      
    setLoaded(false);
  }    
}, [r,s,]);
  
return (<section>
          <table>
            <tbody>
              <CTRow samples={res} />
            </tbody>
          </table>
       </section>
);

This shows up the three dots when longCalcFunc is processing, and hides it is done. However, it does not 'play' the animation as expected. I thought it was related to rendering, but I could not find the exact solution to play the animation while processing/awaiting longCalcFunc.

Is there a viable solution that I should take?

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