Use click away

Detect if a click event happened outside of an element.

This is custom React Hooks, you need to follow the Basic Rules when you use it.

Standard

Click outside the green card to trigger the callback.

APIs / Schnittstellendokumentation

useClickAway

const useClickAway = (
  ref: MutableRefObject<HTMLElement | null>,
  handler: (event: Event) => void,
) => void

Co-Creators