File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/hooks/useEventListener Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments