I am curious about the difference between useEffect
and useCallback
.
const onUpdate = useCallback(() => {
firebase
.firestore()
.collection('answer')
.where('questionUid', '==', questionUid)
.get()
.then((snap) => {
const answer = snap.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}));
setAnswers(answer);
});
}, [answers]);