in my next 13 app i'm using dynamic route and fetching firestore data. when i'm routing i'm passing the doc id and fetch the doc with that id. the fetching part is working but the issue is when i try to update the usesetate object it's not updating at all.
in my dynamic page
const [datas, setDatas] = useState({});
const getData = async () => {
const docRef = doc(db, "livingPosts", homeid);
const docSnap = await getDoc(docRef);
setDatas(docSnap.data());
console.log(datas); // returns undefined
console.log(docSnap.data()); // returns the data
};
useEffect(() => {
getData();
}, []);
why is it not updating?