Safely applies events when the component mounts and cleans it up when it gets unmounted. Also allows you to supply a function to apply the events to a Element, Window or Document.
useEventListener<"scroll">(event: "scroll", listener: Arrayable<(this: Window, ev: Event) => any>, options?: AddEventListenerOptions & {
ref?: (() => EventTarget | null) | null;
}): void
useEventListener(
"scroll",
(e: Event
e) => {
// code goes here
},
{
ref?: (() => EventTarget | null) | null | undefined
ref: () => var document: Document
[MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/document)document,
}
)