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
useEventListener is actually usable with SVG Elements (like <circle />) but this rejects accepting SVG Elements refs.
<circle />
You can try this with https://stackblitz.com/edit/vitejs-vite-hyclkt?file=src%2FApp.tsx
import { useRef, useState } from 'react'; import { useEventListener } from 'usehooks-ts'; function App() { const [hovering, setHovering] = useState(false); const ref = useRef<SVGCircleElement>(null); useEventListener( 'mouseenter', () => { setHovering(true); }, ref ); useEventListener( 'mouseleave', () => { setHovering(false); }, ref ); return ( <svg width="400" height="400"> <circle ref={ref} cx={100} cy={100} r={50} fill={hovering ? 'red' : 'cyan'} stroke="black" style={{ cursor: 'pointer', }} /> </svg> ); } export default App;
Can be built with type-check succeeded.
interface SVGCircleElement extends SVGGeometryElement {} interface SVGGeometryElement extends SVGGraphicsElement {} interface SVGGraphicsElement extends SVGElement, SVGTests {} interface SVGElement extends Element, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrSVGElement {} interface SVGTests has no super-interfaces. interface Element extends Node, ARIAMixin, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slottable {}
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
useEventListener is actually usable with SVG Elements (like
<circle />
) but this rejects accepting SVG Elements refs.To Reproduce
You can try this with https://stackblitz.com/edit/vitejs-vite-hyclkt?file=src%2FApp.tsx
Expected behavior
Can be built with type-check succeeded.
Additional context
The text was updated successfully, but these errors were encountered: