We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4fbfe9d commit c4472a3Copy full SHA for c4472a3
1 file changed
src/hooks/useEventListener/useEventListener.ts
@@ -39,6 +39,21 @@ import { usePreservedCallback } from '../usePreservedCallback/index.ts';
39
* }
40
*
41
* @example
42
+ * function ScrollTracker() {
43
+ * const scrollRef = useRef<HTMLDivElement>(null);
44
+ *
45
+ * useEventListener('scroll', () => {
46
+ * console.log('Scroll event detected!');
47
+ * }, scrollRef, { passive: true });
48
49
+ * return (
50
+ * <div ref={scrollRef} style={{ height: '100px', overflowY: 'scroll' }}>
51
+ * <div style={{ height: '300px' }}>Scroll Me!</div>
52
+ * </div>
53
+ * );
54
+ * }
55
56
+ * @example
57
* function Document() {
58
* useEventListener('click', (event) => {
59
* console.log('Document clicked at coordinates', event.clientX, event.clientY);
0 commit comments