Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 5, 2022 07:30 pm GMT

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 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; };

Original Link: https://dev.to/cuadroscode/drag-and-drop-bj1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To