-
-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
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
Support SVGElement for useEventListener #547
Conversation
🦋 Changeset detectedLatest commit: 9e8eba4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
hmm, with quick look, I believe it's false-positive case of function useEventListener<
- K extends keyof SVGElementEventMap,
+ K extends keyof HTMLElementEventMap | keyof SVGElementEventMap,
T extends SVGElement,
>( Something like this unification may not resolve the problem caused even if adopting the suggestion made by this rule. I'll dive into it afterward, and if it would be found to be false-positive, I'll open the issue on typescript-eslint. |
Hi @LumaKernel, I fixed it that way, merging the // Element Event based useEventListener interface
function useEventListener<
K extends keyof HTMLElementEventMap & keyof SVGElementEventMap,
T extends Element = K extends keyof HTMLElementEventMap
? HTMLDivElement
: SVGElement,
>(
eventName: K,
handler:
| ((event: HTMLElementEventMap[K]) => void)
| ((event: SVGElementEventMap[K]) => void),
element: RefObject<T>,
options?: boolean | AddEventListenerOptions,
): void |
Great! Thank you 🐈⬛ |
Resolves #546