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

180
Views
React state is always false even if it set explicitly

I have a react app which basically wants to give some special permission if the logged in user is an admin. For this i have a table in the db where I store all administrator emails.

I have an UseEffect which I use to verify the current logged in user if it is available in the admin user db.

  useEffect(() => {
    const getUsers = async () => {
      const data = await getDocs(adminUsersCollectionRef);

      console.log(data);

      const user = data.docs.find((x) => x.data().email === currentUser.email);
      console.log(user.data());
      if (user && user.data()) {
        console.log("inside if")
        setIsAdmin(true);
      }
      setTimeout( () => {console.log("Admin este :" + isAdmin)}, 2000);
    };

    getUsers();
  }, []);

My problem is the following: const [isAdmin, setIsAdmin] = useState(false); my isAdmin state will always be false, even if I explicitly set it inside my if condition.

Thank you in advance!

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!