Skip to content

useEventListener ​

Category
Browser

hook to attach an event listener to a target element, document, or window.

typescript
import { useEventListener } from '@elysiumorg/solid-use';

Usage ​

typescript
// Using with window useEventListener(window, 'resize', () = > console.log('window resized'));

Demo ​

Api ​

Parameters

NameTypeDefaultNote
target?Target-The target to attach the event listener to.
eventEvent | Event[]-The event(s) to listen for.
listener(event: any) => void-The callback function to be executed when the event is triggered.
options?UseEventListenerOptions-The options for the event listener.