In this article, we’re going to learn how to implement a click outside functionality using different React techniques like Hooks and Classes. Then, we will consider unit testing using Enzyme and React Testing Library.
If you’ve used hooks at all, you’ll know that one limitation is not being able to conditionally call them in the render body of your component. So what can we do if we really need to call a hook conditionally?
You have probably had to implement debounce in your React applications, this is how you can abstract it into a reusable hook.