skip to Main Content

Setting a state but still getting error when trying to use after it – Reactjs

I'm trying to get pinned article const getCurrentlyPinned = async() =>{ setLoader(true) await firestore() .collection('admin_control') .doc('currently_Pinned') .get() .then(snapshot =>{ const data = snapshot.data(); setpinnedNewsID(data.pinnedNewsId) }) } useEffect(() => { getCurrentlyPinned().then(()=>{ console.log(pinnedNewsID) }) }, []) therefore calling it from useEffect and…

VIEW QUESTION
Back To Top
Search