Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Typescript – DragEvent: errors

Does anyone know why I have this kind of errors? I don’t want to use the older approach with React.DragEvent.

"No overload matches this call."

 const handleDragOver = (e: DragEvent) => {
    e.preventDefault();
  };

 const dragOver = (e: DragEvent) => {
    e.preventDefault();
  };

<tr onDragOver={dragOver} 
    onDrop={(e) => handleDrop(e, item.id)}>

and the second error when the e is called:
"Argument of type ‘DragEvent’ is not assignable to parameter of type ‘DragEvent’.
Type ‘DragEvent’ is missing the following properties from type ‘DragEvent’: layerX, layerY, offsetX, offsetY, and 16 more."

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The DragEvent type you’re using comes from the DOM API.In React, you should use React.DragEvent instead of DragEvent for event handlers like onDragOver:

const handleDragOver = (e: React.DragEvent<HTMLTableRowElement>) => {
 e.preventDefault();
};

<tr onDragOver={handleDragOver}></tr>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading