What is the TypeScript definition for the onPointerCancelCapture event in React?
The right interface for onPointerCancelCapture is PointerEvent
Please continue reading below to see how to use it or read my guide on using React events with TypeScript.
You can also go to the search page 🔍 to find another event.
Interface
interface PointerEvent<T = Element> extends MouseEvent<T, NativePointerEvent> {
pointerId: number;
pressure: number;
tangentialPressure: number;
tiltX: number;
tiltY: number;
twist: number;
width: number;
height: number;
pointerType: 'mouse' | 'pen' | 'touch';
isPrimary: boolean;
}
Full example
import React, { PointerEvent } from 'react';
const App = () => {
const handlePointerEvent = (e: PointerEvent<HTMLDivElement>) => {
// Do something
};
return <div onPointerCancelCapture={handlePointerEvent}>{/** Some code */}</div>;
};
export default App;
Attributes that use PointerEvent:
- onPointerDown
- onPointerDownCapture
- onPointerMove
- onPointerMoveCapture
- onPointerUp
- onPointerUpCapture
- onPointerCancel
- onPointerCancelCapture
- onPointerEnter
- onPointerEnterCapture
- onPointerLeave
- onPointerLeaveCapture
- onPointerOver
- onPointerOverCapture
- onPointerOut
- onPointerOutCapture
- onGotPointerCapture
- onGotPointerCaptureCapture
- onLostPointerCapture
- onLostPointerCaptureCapture