Skip to content

Commit 05785db

Browse files
committed
cleanup queue on unmount
1 parent c7095a7 commit 05785db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

components/use-live-comments.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ export default function useLiveComments (rootId, after, sort) {
3535

3636
// update latest timestamp to the latest comment created at
3737
setLatest(prevLatest => getLatestCommentCreatedAt(data.newComments.comments, prevLatest))
38-
console.log('latest', latest)
3938
}, [data, client, rootId, sort])
39+
40+
// cleanup queue on unmount to prevent memory leaks
41+
useEffect(() => {
42+
return () => {
43+
queue.current = []
44+
}
45+
}, [])
4046
}
4147

4248
// the item query is used to update the item's newComments field

0 commit comments

Comments
 (0)