-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Description
If we pass element ref as below
const counterEl = useRef(null);
useEventListener('click', () => alert('Ref click'), counterEl);
return (
<div className="App">
Count: <span ref={counterEl}>{count}</span>
<button onClick={increment}>+</button>
</div>
);
But, It will work If we pass elementRef.current as below
useEventListener('click', () => alert('Ref click'), counterEl.current);
Will suggest a change, and If you allow will create a PR with the following change
const targetIsRef = element.hasOwnProperty('current');
const currentTarget = targetIsRef ? element.current : element;
const isSupported = currentTarget && currentTarget.addEventListener;
wahlstedt
Metadata
Metadata
Assignees
Labels
No labels