---
title: "Comment by Noël Cserépy on \"Show tooltip on selected text using custom hook\" | Hashnode"
description: "Very cool! I never knew that selection has so much cool stuff to fiddle around with. A quick question: wouldn&#39;t you want to return an unsubscribe() function"
url: "https://hashnode.com/posts/show-tooltip-on-selected-text-using-custom-hook/64f0bcc6f55331966c117b3b/comment/64f461c76ca042857b453e91"
---

[Discussion](https://hashnode.com/posts/show-tooltip-on-selected-text-using-custom-hook/64f0bcc6f55331966c117b3b)

Comment [Show tooltip on selected text using custom hook](https://hashnode.com/posts/show-tooltip-on-selected-text-using-custom-hook/64f0bcc6f55331966c117b3b)

[Noël Cserépy](https://hashnode.com/@noelcserepy)

[Sep 3, 2023](https://hashnode.com/posts/show-tooltip-on-selected-text-using-custom-hook/64f0bcc6f55331966c117b3b/comment/64f461c76ca042857b453e91)

Very cool! I never knew that selection has so much cool stuff to fiddle around with.

A quick question: wouldn't you want to return an `unsubscribe()` function from the event listener in your `useEffect()` to clean up the listener when the component unmounts?

Thanks for the article :D

[Dev Shekhawat](https://hashnode.com/@devcodesthings)

[Sep 3, 2023](https://hashnode.com/posts/show-tooltip-on-selected-text-using-custom-hook/64f0bcc6f55331966c117b3b/comment/64f461c76ca042857b453e91#reply-64f475cab2147985ab4eda95)

I got too excited it worked I forgot about cleanup. 🤦🏻 Thanks. I will update.
