---
title: "Comment by Bhargav Ponnapalli on \"How to close the dropdown when clicked outside its division in React.\" | Hashnode"
description: "Good one Shivam Sharma . I wrote a hook called to do this as well. Clicking outside is a very common feature for dropdowns, modals etc. So I made this hook. htt"
url: "https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1/comment/60118228c497f64171a4dc1f"
---

[Discussion](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1)

Comment [How to close the dropdown when clicked outside its division in React.](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1)

[Bhargav Ponnapalli](https://hashnode.com/@codewithbhargav)

[Jan 27, 2021](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1/comment/60118228c497f64171a4dc1f)

Good one [Shivam Sharma](https://hashnode.com/@shvmsrma).

I wrote a hook called to do this as well. Clicking outside is a very common feature for dropdowns, modals etc. So I made this hook.

[react-hooks.org/docs/use-outside-click-ref](https://react-hooks.org/docs/use-outside-click-ref/) Check it out if you get a chance!

Cheers!

[Shivam Sharma](https://hashnode.com/@shvmsrma)

[Jan 27, 2021](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1/comment/60118228c497f64171a4dc1f#reply-601188889cf50569ae1bda82)

Wow! that was pretty simple, surely gonna use it. Thanks:)

[Rutik Wankhade](https://hashnode.com/@rutikwankhade)

[Jan 28, 2021](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1/comment/60118228c497f64171a4dc1f#reply-601252a08b620b1d6bdf8420)

This is great. I needed this for modals. 🙌 Thanks [Bhargav Ponnapalli](https://hashnode.com/@imbhargav5)

[Bhargav Ponnapalli](https://hashnode.com/@codewithbhargav)

[Jan 28, 2021](https://hashnode.com/posts/how-to-close-the-dropdown-when-clicked-outside-its-division-in-react/60117f452426ce41970734a1/comment/60118228c497f64171a4dc1f#reply-6012536fe8f6da1d3fdfffe5)

Check out react-hooks.org. There should be quite a few hooks that you can use. Of course you can install all or one by one, they are ESM compatible so you won't have more hooks than you need in the final bundle. [Rutik Wankhade](https://hashnode.com/@rutikwankhade)
