Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 426 Bytes

useEventListener.md

File metadata and controls

23 lines (16 loc) · 426 Bytes

useEventListener

Provide a declarative way for events listeners.

Usage

import { useEventListener } from 'use-haki';

const App = () => {
  useEventListener(document, 'click', (event) => console.log(event));
};

Reference

useEventListener(element, eventName, handler);
  • element - reference to element
  • eventName - name of event, eg. 'click'
  • handler - event listener callback