We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RefObject
useEventListener
The target in useEventListener should also support RefObjects for ease of use.
export function useEventListener<T extends HTMLAnchorElement, K extends keyof HTMLElementEventMap>( target: T | RefObject<T> | undefined, type: K, listener: (this: HTMLAnchorElement, event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions, ): void; { const _target = target !== undefined && 'current' in target ? target.current : target; useEffect(() => { _target?.addEventListener(type, listener, options); return () => { _target?.removeEventListener(type, listener, options); }; }, [_target, type, listener, options]); }
The text was updated successfully, but these errors were encountered:
Please check the RefObjectOption<T> in #115, that type and the utility can be used for this change.
RefObjectOption<T>
Sorry, something went wrong.
Update event listener hooks
9c1957f
- Remove useEventListener function overloads - Remove useDocument hook - Remove useWindow hook - Add useDocument hook - Add useWindow hook - Add RefObjectOption to useEventListener for ref support #101 #102
Merge remote-tracking branch 'origin/main' into #102-allow-ref-object…
69ee986
…-in-use-event-listener
Update event listener hooks (#118)
09fe1e8
* Update event listener hooks - Remove useEventListener function overloads - Remove useDocument hook - Remove useWindow hook - Add useDocument hook - Add useWindow hook - Add RefObjectOption to useEventListener for ref support #101 #102 * Remove invalid parameters in docs * Create isRefObject function See: #118 (comment) * Rename getRefObjectOption to unref * Remove unnecessary useDocument and useWindow hooks * Update src/utils/unref/unref.mdx Co-authored-by: Arjan van Wijk <[email protected]> --------- Co-authored-by: Arjan van Wijk <[email protected]>
leroykorterink
No branches or pull requests
The target in
useEventListener
should also support RefObjects for ease of use.The text was updated successfully, but these errors were encountered: