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

140
Vistas
Display Loading spinner whilst data is fetching

How can show a loading spinner whilst the data is loading to fetch.

const [user, loading, error] = useAuthState(auth);
const navigate = useNavigate()
const [bikes] = useBikes()

if (loading) {
  return  <Loading></Loading>
}
            
fetch(`http://localhost:5000/bike/${id}`, {
    method: 'DELETE'
})
  .then(res => res.json())
  .then(data => {
      console.log(data)
      alert('One Item Deleted')
   });
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you have the spinner under the id spinner here's a minimalistic example on how you can do so. just wrap the fetch inside a function.

function delitem(){
  document.getElementByID("spinner").style.display = "block"
  fetch(`http://localhost:5000/bike/${id}`, {
    method: 'DELETE'
    })
    .then(res => res.json())
    .then(data => {
      console.log(data)
      alert('One Item Deleted')
      document.getElementByID("spinner").style.display = "none"
   });
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

Put your fetch API inside the useEffect, so you can easily implement your spinner functionality

const [isLoading,setIsLoading]=useState(false);


useEffect(()=>{
 setIsLoading(true);
 fetch("some-url").then(res=>res.json())
  .then(data=>{
  setIsLoading(false)
  console.log(data);
},[])

if(isLoading){
 return <LoadingSpinner/>
}

return <div>..your data </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