Create a Dropdown in React that Closes When the Body is Clicked

added by JavaScript Kicks
12/24/2018 8:44:19 AM

357 Views

In this lesson we'll create a dropdown menu that is toggle via a button setting state. We'll then setup a ref to get access to the container div. Finally using event listeners on the document body we will check if the user clicked anywhere outside of our dropdown and then close the dropdown.


0 comments