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

91
Vistas
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 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