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

175
Vistas
How to add loader to website while Axios is getting data?

I'm getting my data at very slow rate so when i open my website first time it takes some times untile showing all the product. So i want to add a loader untile my data is fully loaded.

i used custom Hook to load data

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One way of doing this, that I like, and is very straight forward is by adding conditional statements, meaning that if the data passed as a prop is currently undefined return <div>Loading.....</div> in opposite case return the JSX containing the prop data.

If you don't do this, React will show an error. This is because when fetching there is a time that the data is undefined and if React tries to do something with it before hand, it finds nothing. This conditions are a way to tell React when is a good time to access the data.

export default function MyComponent({someData}){

  if(!someData) return <div>Loading.....</div>
  else{
     return <div>{someData}</div>
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
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