Drag and Drop in React

In this example it was created whit React and typescript

Drag and drop area

<div
onDrop={handleDrop}
onDragOver={handleDragOver}
onDragEnter={handleDragEnter}
onDragLeave={handleDragLeave}
>
</div>

Actions

const h…


This content originally appeared on DEV Community and was authored by kevin david cuadros

In this example it was created whit React and typescript

  • Drag and drop area
<div
  onDrop={handleDrop}
  onDragOver={handleDragOver}
  onDragEnter={handleDragEnter}
  onDragLeave={handleDragLeave}
>
</div>
  • Actions
  const handleDragOver = ( e: DragEvent<HTMLDivElement>) => {
    e.preventDefault();
    e.stopPropagation();
  };

  const handleDragEnter = ( e: DragEvent<HTMLDivElement>) => {
    e.preventDefault();
    e.stopPropagation();
  };

  const handleDragLeave = ( e: DragEvent<HTMLDivElement>) => {
    e.preventDefault();
    e.stopPropagation();
 };

 const handleDrop = ( e: DragEvent<any>) => {
    e.preventDefault();
    e.stopPropagation();
    // the 'files' constant contains the documents
    const files = e.dataTransfer.files;
 };


This content originally appeared on DEV Community and was authored by kevin david cuadros


Print Share Comment Cite Upload Translate Updates
APA

kevin david cuadros | Sciencx (2022-04-05T19:30:54+00:00) Drag and Drop in React. Retrieved from https://www.scien.cx/2022/04/05/drag-and-drop-in-react/

MLA
" » Drag and Drop in React." kevin david cuadros | Sciencx - Tuesday April 5, 2022, https://www.scien.cx/2022/04/05/drag-and-drop-in-react/
HARVARD
kevin david cuadros | Sciencx Tuesday April 5, 2022 » Drag and Drop in React., viewed ,<https://www.scien.cx/2022/04/05/drag-and-drop-in-react/>
VANCOUVER
kevin david cuadros | Sciencx - » Drag and Drop in React. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/05/drag-and-drop-in-react/
CHICAGO
" » Drag and Drop in React." kevin david cuadros | Sciencx - Accessed . https://www.scien.cx/2022/04/05/drag-and-drop-in-react/
IEEE
" » Drag and Drop in React." kevin david cuadros | Sciencx [Online]. Available: https://www.scien.cx/2022/04/05/drag-and-drop-in-react/. [Accessed: ]
rf:citation
» Drag and Drop in React | kevin david cuadros | Sciencx | https://www.scien.cx/2022/04/05/drag-and-drop-in-react/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.