So I'm trying to use React Query with Firestore and usually this works pretty fine but recently I have been unable to make a function that returns a value.
const fetchProduct = async () => {
  const querySnapshot = await getDocs(collection(db, "notes"));
  const arr = [];
  querySnapshot.forEach((doc) => {
      setNotes(doc.data())
  }).catch((error) => {
      console.log(error);
      return null;
  });
  return notes
}
I'm later trying to use this function with React Query like this -
const { isLoading, isError, data, error } = useQuery(['todos'], fetchProduct)
However the value of the {data} always return to undefined but however once the fetchProduct() function is called manually it all works.
Is there anything I'm missing or doing wrong?
 
     
    