Код: Выделить всё
const [user, setUser] = useState(null);
const [err, setErr] = useState(false);
const q = query(collection(db, "users"), where("displayName", "==", username));
try {
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
const userData = doc.data();
setUser(userData);
});
} catch (err) {
setErr(true);
}
if (!user) {
console.error("User not found");
return;
}
console.log("User found:", user);`
Подробнее здесь: https://stackoverflow.com/questions/793 ... n-firebase