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

96
Views
call api and render data after states get updated

In use effect I am checking current role of user, if it is admin setAdmin(true) set the state of admin. The default admin state is false. When component gets rendered, it gets rendered with admin as false and state gets updated in sometime. I want to call api and render data after state gets updated.

useEffect(async () => {
    //Authenticates User through their email
    let firebaseId;
    const user = await firebase.auth().currentUser;
    if (user) {
      let getUserProfile = async () => {
        let loggedInUser = await axios.get(
          `${config.API_URL}/data/profile/${user.uid}`
        );
        if (loggedInUser.data.role == "admin") {
          setAdmin(true);
        }
      };
      getUserProfile();
    }
}, []);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use useEffect hook in above case.

Ex:

useEffect(() => {
   // Call your API
}, [admin]);

Above hook will call when admin state updated.

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!