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

164
Views
How do I refresh parent component when I successfully make API call from child component, which is a modal?

I have home page with a table having few entries. Above table I have button called add entry. When user clicks on add entry, it opens a modal, where user can add few details and submit it. The submit button makes API call to store the data in database. Once the API call is successful, the modal closes. Now , how do I refresh the parent component after modal closes so that the newly added data can be shown in table (which is loaded via API call). I'm using functional components. I'm looking for steps that I should follow, not full code (pseudo code will do ). I'm not using redux. i dont want to do winow.reload(). as it reloads the whole page.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

make an async fetchData function that will fetch you table data all you have passed that fetchData function to modal and on success call that fetch function

const [loading,setLoading] = useState(false)
const [data,setData] = useState()

  const fetchPlans = async () => {
    try {
      setLoading(true);
      const getDataRes = await getData();
      // save that data in state that will reredener page
      setData(getDataRes.data);
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    } catch (error) {
      console.log(error)
    } finally {
    setLoading(false);
    }  
   };
</>
about 4 years ago · Juan Pablo Isaza Report

0

You can create a callback function in the parent component and pass it to children component as a property

about 4 years ago · Juan Pablo Isaza Report
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!