Skip to content

Commit c4472a3

Browse files
committed
docs(hooks/useEventListener.ts): add 'ScrollTracker' example in JSDoc
1 parent 4fbfe9d commit c4472a3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/hooks/useEventListener/useEventListener.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ import { usePreservedCallback } from '../usePreservedCallback/index.ts';
3939
* }
4040
*
4141
* @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
4257
* function Document() {
4358
* useEventListener('click', (event) => {
4459
* console.log('Document clicked at coordinates', event.clientX, event.clientY);

0 commit comments

Comments
 (0)