Drag and drop from scratch with React
· 5 min read
Intro
In this tutorial I will show how to make a Drag and Drop component from scratch with no 3rd party libraries using React.
Important info
-
There exists the event handler
e.dataTransferwhich helps with drag and drop functionality, but as we're using React I find using state to be simpler. -
Make sure to check out the Code Sandbox. I may add a few things that aren't reflected below, but the code below is complete.
-
You might know a better way to do this! If you think you can improve the code please comment.