Hacker News new | past | comments | ask | show | jobs | submit login
React hook to detect click or touch events (github.com/geobde)
2 points by geobde on July 28, 2020 | hide | past | favorite | 1 comment



React hook useClickAway() that reacts to clicks outside the bound element, and calls the expression that is passed in when this event is detected.

Suppose you're working on a Modal component that renders a dialog box, and you wish to close the modal if the user clicks away this is the ideal scenario for useClickAway() custom hook.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: