What is the TypeScript definition for the onDragEnterCapture event in React?
The right interface for onDragEnterCapture is DragEvent
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 DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
dataTransfer: DataTransfer;
}
Full example
import React, { DragEvent } from 'react';
const ButtonComponent = () => {
const handleDragEvent = (e: DragEvent<HTMLDivElement>) => {
e.preventDefault();
// Do something
};
return <div onDragEnterCapture={handleDragEvent}>Drag me!</div>;
};
export default ButtonComponent;