A React Hook that use EventListener
with ease.
Register using addEventListener
on mounted, and removeEventListener
automatically on unmounted.
Double-click anywhere on the window, or click inside the dotted box below to see the Toast prompt.
Click inside this dashed box to see the toast
See API for more details.
Click links below to view source on GitHub.
Target can be:
A "⚛️" prefix is means that it can also be a React Ref that contains it.
window
(default)document
EventTarget
interface (addEventListener
and removeEventListener
)null
or undefined
string | string[]
, a string
or strings
representing the event types to listen for. It will be automatically inferred from the EventTarget
type.
Function | Funtions[]
, a function
or funcitons
that receives a notification when an event of the specified type occurs. Event
will also be automatically.
Options that will be passed to addEventListener
and removeEventListener
.
For more details options, see EventTarget.addEventListener#options
A function
that removes the event listener.