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

174
Vistas
How can I render components again after receiving data using axios in React.js?

I am making a web application that fetches data from API using axios, and showes the data.
However, fetching API takes too long, so I used Loader component, and after the axios GET method is over, I wanted to show the fetched data.
But my problem is, it fetches with no errors, Loader works perfect, and after fetching is done, Loader goes off. But my mapped data does not render on web. How can I fix this problem?

  const [isLoading, setLoading] = useState(true);
  const [lunchData, setLunchData] = useState(mockServingData);

  useEffect(() => {
    axios.get(URL).then((response) => {
      setLunchData(response.data.menu[0].lunch);
      lunch = lunchData.lunch;
      setLoading(false);
    });
  }, []);
  

  if (isLoading) {
    return <div className="App"><Loader type="spin" color="RGB 값" message="Loading..." /></div>;
  }
  const lunchMenuList = lunch.map((menu, index) => (
    <li key={index}>{menu}</li>
  ));


  return (
    <div className="App">
      {lunchMenuList}
    </div>
  );
  • I used var lunch just in development process, because mockServingData is not in the perfect form.
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