Skip to content

Commit 28a1ae9

Browse files
committed
task finished
1 parent bb1a2e8 commit 28a1ae9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/tree/Tree.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ const Tree: FC<Props> = ({ data, treeId }: Props) => {
7474

7575
useEffect(() => {
7676
if (!firebase) return;
77-
firebase
78-
.database()
79-
.ref(`stars/${treeId}`)
80-
.on("value", (snapshot) => setStar(snapshot.val()));
77+
const ref = firebase.database().ref(`stars/${treeId}`);
78+
ref.on("value", (snapshot) => setStar(snapshot.val()));
79+
return () => {
80+
ref.off();
81+
};
8182
}, [firebase, treeId]);
8283

8384
const toggleStar = useCallback(

0 commit comments

Comments
 (0)