Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
#129 Fixed unsubscribe error
Browse files Browse the repository at this point in the history
  • Loading branch information
MilitsaB committed Mar 27, 2022
1 parent 0f82682 commit 12531ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/chat/PatientChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ function PatientChat() {
const [user, setUser] = useState<DocumentData>();

useEffect(() => {
onSnapshot(doc(firestore, 'users', `${state.id}`), (docu) => {
const unsubscribe = onSnapshot(doc(firestore, 'users', `${state.id}`), (docu) => {
const data = docu.data();
if (data) {
setUser(data);
}
});

// eslint-disable-next-line react-hooks/exhaustive-deps
return () => {
unsubscribe();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down

0 comments on commit 12531ea

Please sign in to comment.