Drag and drop in react was a lot easier than I thought

  Рет қаралды 122,017

Web Dev Cody

Web Dev Cody

Күн бұрын

💬 Discord / discord
🔔 Newsletter newsletter.web...
📁 GitHub github.com/web...
📺 Twitch / webdevcody
🤖 Website webdevcody.com
🐦 Twitter / webdevcody

Пікірлер: 108
@dhunsworth
@dhunsworth Жыл бұрын
I always had in my mind that this would be super complex and definitely a situation to go looking for some package that would make it reasonable. Thanks for showing us this!
@WebDevCody
@WebDevCody Жыл бұрын
Glad it was helpful!
@buraksurumcuoglu8303
@buraksurumcuoglu8303 Жыл бұрын
I just got out of a meeting on my dev job and we talked about a new page with drag and drop functionality, your timing is incredible 😅
@blackpurple9163
@blackpurple9163 Жыл бұрын
It's KZbin algorithm at work
@amarcampbell4542
@amarcampbell4542 Жыл бұрын
Perfect timing 👌
@saman6199
@saman6199 Жыл бұрын
This is awesome, I always avoided to even try this feature, because I thought it could be complicated. But you made it look so easy with your walkthrough. Will definitely give it a shot. Thanks for your effort 😊
@Earth_Elegance_
@Earth_Elegance_ 3 ай бұрын
seriously. me too
@selahadinjemal7138
@selahadinjemal7138 5 ай бұрын
I just saw this in a job posting as a best to have skill and wanted to check it out. simple, effective, no blabber. Thanks!
@51Grimz
@51Grimz Жыл бұрын
Useful video on a quick and simple native drag and drop without any libraries or anything! Follow up to this would be dragging and dropping in any index of the droppable area. Say you drag Widget C in between Widget A and B. Not just appending it to the end.
@estoupensa27
@estoupensa27 Жыл бұрын
Do you know how to drag and drop inside of the droppable area?
@saladin_advanced
@saladin_advanced 21 күн бұрын
Best video explaining drag n drop.
@Earth_Elegance_
@Earth_Elegance_ 3 ай бұрын
Thank you. This is easy than I thought. I realized it because of you
@Rico-cp4xp
@Rico-cp4xp 5 ай бұрын
Been looking into dnd lately, crazy how simple that is. Great video as always 👍
@Gabrielmo00
@Gabrielmo00 5 ай бұрын
Best tutotial! I have had trouble with react drag and drop libraries in the past. I was in need to start a new project that woul require a simple drag and drop, and your example give me the kickstart that I need. Thanks man!
@nonstopper
@nonstopper Жыл бұрын
Now make it re orderable
@zzzyyyxxx
@zzzyyyxxx Жыл бұрын
DND Kit makes this super easy to do
@harithmu
@harithmu 7 ай бұрын
you have a repo? because i find it very hard to do it where its something like in vid. (drag n drop but original item still there)
@eveguelarocha9961
@eveguelarocha9961 Жыл бұрын
I think just last week, I needed this kind of code in react, I ended up searching for code then copied and pasted it and just changed variables and stuff and it worked, but this video made me realize I need to recode it and do it with my own logic to improve my skills, Thanks mate! I thought it was so complicated, was thinking to use, dom manipulation etc but i think, i think too much on the problem. Thank you again, will keep following your page for more advice !
@ifeanachofavour409
@ifeanachofavour409 Жыл бұрын
Hi Mind sharing the resource to the code you found.
@FXTripazha
@FXTripazha Жыл бұрын
Easier than I expected, thanks! Subscribed
@Vimal-tr3tl
@Vimal-tr3tl 3 ай бұрын
Minimal much needed. Thank you.
@matze489
@matze489 Жыл бұрын
this is amazing, i thought i would need to use some lib todo that but with knowing these events its actually pretty easy todo it on you own
@ilovelctr
@ilovelctr Жыл бұрын
Wow, thanks a ton for this splendid tutorial! I didn't think this could be implemented using such exquisitely clean code, and thought that it might end up as equally annoying as if otherwise built via vanilla JavaScript and real DOM manipulation. Absolutely appreciate how elegant this is.
@siva002
@siva002 Жыл бұрын
So much easier to understand. Thank you. You saved me the trouble of going with react-dnd or dnd-kit which are very sophisticated, but overkill. As long as we don't need mobile or too much cross browser compatibility ( for example, internal websites), this is more than enough.
@glcorreia
@glcorreia 29 күн бұрын
I thought this would require plugins and a lot more code. Thanks for sharing
@ThisIsLiving__
@ThisIsLiving__ Жыл бұрын
I have always had a project in mind requiring me to use this feature - but eventually, the complexity of my ambition made me never do it but I ll definitely do it now
@ZACKDEV
@ZACKDEV Жыл бұрын
Wow you made learning this super easy, I was looking into this feature recently with a lot of complicated topics. This make is super simple for us to recreate it and experiment!
@andlukas
@andlukas Ай бұрын
i want to reproduce the behavior of google calendar, when you drag the amount of hours of an event
@rredington305
@rredington305 5 ай бұрын
I've got this part sorted 👍🏼 next im working on a DnD sortable list using standard React without success. Pls make a DnD sortable list video 🙏🏻
@blu5037
@blu5037 Жыл бұрын
Nice video! Never implemented this feature, but for a long time I thought we'd have to track the cursor position and everything. Cool to see that it can be implemented with little lines of code.
@MahmoudBA
@MahmoudBA Жыл бұрын
you made it look so easy great work!
@saladin_advanced
@saladin_advanced 21 күн бұрын
It's kind easy finally. thx.
@Ayush_Bob
@Ayush_Bob Жыл бұрын
That was suprisingly easy thanks a lot and easy to build upon
@hellome3046
@hellome3046 3 ай бұрын
thank you very much
@ameen8891
@ameen8891 4 ай бұрын
Thanks BRoo
@tiktalk4573
@tiktalk4573 5 ай бұрын
Thanks this is useful for us!
@noahwinslow3252
@noahwinslow3252 Жыл бұрын
I've been interested in making a game like stacklands for a while, perfect fun project with drag and drop
@ReDestro69
@ReDestro69 11 ай бұрын
Enjoyed this video. Apparently, I'm working on a client project where I'm building a module very similar to DocuSign. I'll be dragging different fields onto the document and assigning users to each field to fill out/sign.
@TheSourLemonz
@TheSourLemonz Жыл бұрын
Very informative, nice work
@MubashirullahD
@MubashirullahD Жыл бұрын
That was so cool. And Im actually going to use for a professional use case. Need to build something to match pictures with words.
@MubashirullahD
@MubashirullahD Жыл бұрын
WIsh the code was on a snippet :)
@TheBswan
@TheBswan Жыл бұрын
Dnd-kit is the best library for this
@ZACKDEV
@ZACKDEV Жыл бұрын
LOL WHAT THE HECK! it literally is the best!
@pauloricardomaltaleal3558
@pauloricardomaltaleal3558 4 ай бұрын
How can i pick the position when drop, according to dimensions of father component?
@xeliqa3921
@xeliqa3921 Жыл бұрын
how convenient. Am actually looking to build a project with this functionality, similar to a trello board.
@haze4828
@haze4828 Жыл бұрын
Would be pretty cool to make it remove the item from the original container once the drop has occurred, although I don't know how long that would take me to figure out 😅
@vydikvaidya654
@vydikvaidya654 Жыл бұрын
Can I know how to display the HTML code for the item when it's dropped
@estheryang6450
@estheryang6450 9 ай бұрын
Thank you for the explanation! Will love to ask what is the name of the extension you use to show component?
@dr.livesey5157
@dr.livesey5157 Жыл бұрын
Thanks!
@ryanwoods3333
@ryanwoods3333 Жыл бұрын
great video! would you consider doing a video in React where a user can click on a product for example and show a pop up modal? So there would be multiple modals with different content. Not sure how to do this in pure React without installing some NPM package...
@WebDevCody
@WebDevCody Жыл бұрын
thank you for the super thanks! I could potentially do that for a react challenge video when I get time
@waytonirvana6426
@waytonirvana6426 Жыл бұрын
clean and helpfull thank you
@chesterxp508
@chesterxp508 9 ай бұрын
GoodJob!
@panagiotiskyriacou61
@panagiotiskyriacou61 11 ай бұрын
imagine that when drop widget tothe left create different categories that group the widget. So also the category component is a drop target. It is possible the category (drop target)be also a draggable item so you can merge two categories?
@eip408
@eip408 Жыл бұрын
Awesome stuff! I was also looking for a way to do this drag n drop functionality because I was doing a personal project like shopify customizer. Thanks!
@maxclouatre2703
@maxclouatre2703 Жыл бұрын
Love this! Custom starter or did you find this in the Vite docs? Thanks!
@WebDevCody
@WebDevCody Жыл бұрын
This is a vite setup
@jorims8537
@jorims8537 Жыл бұрын
nice idea with using the state and just appending elements. However, the usecase for this is very limited. If the position (order) matters in which I would drag my element in, it would obviously not work.
@ifeanachofavour409
@ifeanachofavour409 Жыл бұрын
Hi that is really cool and I do currently have need for a drag and drop implementation. Wanted to ask if you could attach a link to the documentation for this. Hoping to hear from you soon. Thanks
@GabrielWis
@GabrielWis Жыл бұрын
Hi ! I have a problem. When I writing ([]) at state, show error "string is undefined".
@r1nzai
@r1nzai Жыл бұрын
I'd rather use react-beautiful-dnd which is used internally for trello and jira as well, and is like super easy to implement
@keifer7813
@keifer7813 Жыл бұрын
What's the cost though? In terms of bundle size and page speed?
@Victor-dt1uq
@Victor-dt1uq Жыл бұрын
It is no longer maintained though :(
@juanorjuela7161
@juanorjuela7161 7 ай бұрын
Hello, I really liked your video. I would like to know if there is a repository where I could see the code better or collaborate since a couple of ideas occur to me.
@ArynKr
@ArynKr Жыл бұрын
Loved it... Btw what color scheme are you using on vs code?
@WebDevCody
@WebDevCody Жыл бұрын
bearded theme stained blue
@ArynKr
@ArynKr Жыл бұрын
@@WebDevCody Thanks 😀
@deepmane5845
@deepmane5845 Ай бұрын
locally it is easier how about on server save newly formed/droped data to sever but it takes time meanwhile on ui it happens quickly so my app is todo app in which task are divided such way that complete and incomplete if i drag incomplete task to complete it changes data to true on server using redux but on ui it takes time to load again how to deal with my app i hope you understand
@amirshaban7115
@amirshaban7115 Жыл бұрын
Could someone help me out with making it functional with touchEvents instead of dragEvents?
@criztiandev
@criztiandev Жыл бұрын
Hi I just want to ask, how about free drag, could you make a video about it ?
@omomer3506
@omomer3506 Жыл бұрын
Nice, but something i didnt catch, the e.datatranfer carries the actual widget with all of its properties and styles? Ir is something else going jn
@WebDevCody
@WebDevCody Жыл бұрын
It might have a reference to the underlying dragged element, but it’s more for setting custom metadata you can use later when dropping
@oddsquadd
@oddsquadd Жыл бұрын
the issue is that it is not working with mui icons
@ZeNiTh_2K
@ZeNiTh_2K Жыл бұрын
Out of context but which VS Code theme is that ?
@WebDevCody
@WebDevCody Жыл бұрын
Bearded theme stained blue
@CaliburPANDAs
@CaliburPANDAs Жыл бұрын
Have you tried React dndkit?
@WebDevCody
@WebDevCody Жыл бұрын
Not yet
@oguzhan2393
@oguzhan2393 Жыл бұрын
how can I drop the div whereever I want.
@appstuff6565
@appstuff6565 11 ай бұрын
but how do you persist this?
@muhammad-shahin
@muhammad-shahin 8 ай бұрын
can I get this code? did you upload it on github?
@appstuff6565
@appstuff6565 11 ай бұрын
How can we store this new arrangement in a database so it persists?
@appstuff6565
@appstuff6565 11 ай бұрын
you loved the vcomment but can you please guide on something, i am building a linktree clone as a study learnning and i have tables users and links, i fetch links from supabase for that particular user. My main issue is when i fetch links i want them to be fetched as i arrange them in the list. How do i persist that? Thanks.
@Tregadbm
@Tregadbm Жыл бұрын
Wait, how are your elements fully opaque while dragging and animate back on unsuccessful drag? Could it be your browser? I'm using chrome.
@WebDevCody
@WebDevCody Жыл бұрын
Must be built into the browser because I didn’t add styles
@SMTarcisio
@SMTarcisio Жыл бұрын
Hi, I'm from Brazil, I'm new in Javascript and React Js, cool video, so perfectly understandable but I'm trying to make a different thing, an image be drag n drop inside a div and this div has limit of the corners, when the user drag it around off limit of the corner it brings the image back to limit of the div without any package, can you help me with this?
@WebDevCody
@WebDevCody Жыл бұрын
I’m not sure I don’t work much with drag and drop
@artistry7919
@artistry7919 Жыл бұрын
How can we make a drag and drop feature keyboard accessible?
@WebDevCody
@WebDevCody Жыл бұрын
Not sure, maybe enter to select the item, then left and right arrows to move it around between drop zones?
@DekanTrue111
@DekanTrue111 Жыл бұрын
Well does it work with touch? In the past I have had to use react dnd with two logic handlers. Is this not needed anymore?
@WebDevCody
@WebDevCody Жыл бұрын
Oh I didn’t try with touch, good point
@micheledibe
@micheledibe Жыл бұрын
Nice tutorial, well explained, although this implementation, which the native Drag&Drop, is pointless since since is not supported on mobile devices. In other words, lets be honest, we gonna need third party libraries for ever 😂
@jittojoyes7533
@jittojoyes7533 Жыл бұрын
Are you using any package here, like react dnd
@WebDevCody
@WebDevCody Жыл бұрын
Nope
@anagocode
@anagocode Жыл бұрын
is this react-dnd or react-beautiful-dnd ?
@WebDevCody
@WebDevCody Жыл бұрын
This is just html events I think
@shubhampawar7921
@shubhampawar7921 Жыл бұрын
Doesn't work on mobile though.
@umargulzar2982
@umargulzar2982 Жыл бұрын
can you please provide GITHUB link for source code?
@WebDevCody
@WebDevCody Жыл бұрын
sorry I don't think I have it, it's too much work for me to upload code for every single video. Just learn what I taught and re-implement is my suggestion.
@SeibertSwirl
@SeibertSwirl Жыл бұрын
Good job babe!! Also first!
@WebDevCody
@WebDevCody Жыл бұрын
thanks babe! you're back getting first place comments again
@YuriC.
@YuriC. Жыл бұрын
That's not fair, she knows when a video is about to drop 🧐
@WebDevCody
@WebDevCody Жыл бұрын
@@YuriC. insider trading 😂
@someunknowngirl7208
@someunknowngirl7208 Жыл бұрын
Very basic and odd example specially when u do setWidgets and spredding state instead of using cb with prev param
@WebDevCody
@WebDevCody Жыл бұрын
How’s that odd? You don’t need the callback anytime you update state
@muruga3603
@muruga3603 Жыл бұрын
React Drag And Drop (dnd-kit) | Beginners Tutorial
17:27
Code Complete
Рет қаралды 39 М.
How To Build Sortable Drag & Drop With Vanilla Javascript
22:22
Web Dev Simplified
Рет қаралды 331 М.
GTA 5 vs GTA San Andreas Doctors🥼🚑
00:57
Xzit Thamer
Рет қаралды 26 МЛН
Blue Food VS Red Food Emoji Mukbang
00:33
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 34 МЛН
Glow Stick Secret Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 19 МЛН
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 6 МЛН
Building draggable Component with React and TypeScript
11:44
Dive in Dev
Рет қаралды 20 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 614 М.
Decrease Next.js Docker Image Size 15x
5:36
Frontend Basics
Рет қаралды 15 М.
This React Drag and Drop Component Is Magic
9:56
developedbyed
Рет қаралды 89 М.
This is Why Programming Is Hard For you
10:48
The Coding Sloth
Рет қаралды 839 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
Drag And Drop With React Hooks From Scratch
57:35
asat
Рет қаралды 65 М.
I Paid Fiverr Game Developers to Make the Same Game
10:25
BadGameDev
Рет қаралды 686 М.
React Drag and Drop List Sort Tutorial
9:54
Darwin Tech
Рет қаралды 18 М.
How to OVER Engineer a Website // What is a Tech Stack?
11:20
Fireship
Рет қаралды 2,4 МЛН
GTA 5 vs GTA San Andreas Doctors🥼🚑
00:57
Xzit Thamer
Рет қаралды 26 МЛН