Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!