Easy React Drag & Drop tutorial | React Projects

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 127

  • @harrazmasri2805
    @harrazmasri2805 2 ปีที่แล้ว +1

    this, is the start of my journey with react, here we goo

  • @mohaiminulhasan252
    @mohaiminulhasan252 3 ปีที่แล้ว +11

    const dragEnd = e => {
    if (e.target.style.display === 'none') {
    e.target.style.display = 'block';
    }
    }
    The above code will fix the cards getting lost upon unsuccessful drag 'n drops.

  • @Master13656
    @Master13656 5 ปีที่แล้ว +10

    FYI for the reason cards disappear when dropped outside of boards or on top of one another is due to the setTimeout(). Not sure why but with it removed you can no longer drop outside of the board or on top of another card and have it disappear.

    • @atlicervantes6187
      @atlicervantes6187 3 ปีที่แล้ว

      This is why you should always read the comments! Thanks!!

    • @avashurov
      @avashurov 3 ปีที่แล้ว

      Just put display block logic inside drug over handler. It disappears because display is still set to none

  • @maximo5263
    @maximo5263 ปีที่แล้ว

    I can't believe it , it was straight forward and easier than trying to implement a library , lol. Thanks a lot!

  • @mosimiloluwaadebisi4718
    @mosimiloluwaadebisi4718 2 ปีที่แล้ว +1

    Nice one. Thank you for this

  • @geraldwarren5891
    @geraldwarren5891 3 ปีที่แล้ว +1

    Thank you ... great tutorial... as a growing developer im happy to see a community willing to share and help others ... again thank you

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      Glad it was helpful!

  • @siraftel7915
    @siraftel7915 2 ปีที่แล้ว +1

    Thank you so much for the tutorial.
    You teachs me a LOT.
    Have a nice day and stay healthy Trey.

    • @TylerPotts
      @TylerPotts  2 ปีที่แล้ว

      That's what I like to hear! I'm happy it helped!

  • @yaiyai6
    @yaiyai6 4 ปีที่แล้ว +6

    Really easy to understand and replicate. You've helped me solve my final project in my development bootcamp!! You're my hero for the year!! Thank you!!

  • @MicahJohns
    @MicahJohns 4 ปีที่แล้ว +2

    So if that card has data in it, how do you pass that data between those two boards? Especially if they are separate components?

  • @jasa6732
    @jasa6732 3 ปีที่แล้ว +1

    Tyler, Really nice tutorial. You made it easy to understand

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      Glad it was helpful!

  • @amitavamozumder73
    @amitavamozumder73 2 ปีที่แล้ว

    if you want to swap two cards? then what should i change?

  • @Webnoob
    @Webnoob 5 ปีที่แล้ว +2

    Excellent explanation, I like the part with the timeout in your card.js file. You explained and illustrated very well.

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว +1

      Thank you I hope you enjoyed the video! 🔥🌵

    • @Webnoob
      @Webnoob 5 ปีที่แล้ว +1

      @@TylerPotts Yes, I like to watch the work of other developers. Stay tuned ;-)

  • @umangbhatnagar1415
    @umangbhatnagar1415 2 ปีที่แล้ว +2

    Just one query to the content owner!! Normally, it has been suggested over time and again that direct DOM manipulation shall and must be avoided working with react.js. You used the same old HTML way interacting with DOM. Is it because we can't achieve drag&Drop all thoroughly with react.js??

  • @dramastar30
    @dramastar30 3 ปีที่แล้ว

    Cool... Just what was I looking for. Thanks man 👍🏻. Awesome tutorial.

  • @franciscogaxiola9450
    @franciscogaxiola9450 2 ปีที่แล้ว

    Please, could you share to us that beautiful VSCode theme and setup? That dark green look and feel makes me want to code insanely.

  • @ManikPokhetra79
    @ManikPokhetra79 3 ปีที่แล้ว +1

    Really nice tutorial. Needed something like this for my next project

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว +1

      Great to hear!

  • @brandon.duffany
    @brandon.duffany 4 ปีที่แล้ว +3

    The intro to this tutorial was unexpectedly hilarious

  • @logancurtis5134
    @logancurtis5134 3 ปีที่แล้ว

    Would you be able to now take the state and save it so that the state saved could be re rendered elsewhere within the webapp? Great tutorial

  • @pratikartik
    @pratikartik 3 ปีที่แล้ว +1

    thankyou sooo much vroooo

  • @AlfredAyache
    @AlfredAyache 4 ปีที่แล้ว

    Thank you, first, for a very good explanation of vanilla drag and drop within a React app. I was a little disappointed right at the end when you left it with a pretty huge bug, though. On the other hand, that's kind of leaving it as an exercise for the class. So, again, thank you.

  • @ptsgrdptsgrd
    @ptsgrdptsgrd 3 ปีที่แล้ว +1

    Thank you so much for making a great easy to understand tutorial!!

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว +1

      Glad it was helpful!

  • @malihal3056
    @malihal3056 3 ปีที่แล้ว

    This is an awesome tutorial, thank you! Worried this was going to take a long time but you did a great job explaining!

  • @NotTheLastOne
    @NotTheLastOne 3 ปีที่แล้ว

    react is about working with the state not with the DOM elements. how do you save changes in the state?

  • @ryandsouza7100
    @ryandsouza7100 5 ปีที่แล้ว +1

    Great video Tyler. Keep em coming.

  • @SACHIN-gd6zy
    @SACHIN-gd6zy 4 ปีที่แล้ว +8

    I really like that setTimeout, once in a interview they asked me why setTimeout (fn,0) is usefull but I fail to give the answer,If you don't mind can u tell me what are some other good uses of setTimeout 0 and maybe a good understandble definition :)

    • @dallas-cole
      @dallas-cole 4 ปีที่แล้ว +5

      stackoverflow.com/questions/779379/why-is-settimeoutfn-0-sometimes-useful o7

  • @karudish
    @karudish 2 ปีที่แล้ว

    Great tutorial!

  • @Ardiansyah-cx9ew
    @Ardiansyah-cx9ew 4 ปีที่แล้ว

    easy to understand, great bro

  • @Mvrck44
    @Mvrck44 4 ปีที่แล้ว +1

    Loved it, cheers!

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว

      Glad you enjoyed it!

  • @xtereone
    @xtereone 3 ปีที่แล้ว

    What kind of extension VSCode you use to get such us interface?

  • @timorsulimani1906
    @timorsulimani1906 5 ปีที่แล้ว +2

    And if we want to copy the item instead of moving it? what should we do?

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      If you want to copy an item them all you would need to do is add a duplicate button to the card so when you click it , it copy's the inside data and creates a new card

    • @mattyo7883
      @mattyo7883 5 ปีที่แล้ว

      @@TylerPotts Hi Tyler. First I want to say I love this video, it is very helpful. Can you please explain how to do this copy item more? I used the cloneNode and it works for dragging a copy over the first time, but after that, if you try to drag the copy, the copied card is null and it fails. If you could help, I would really appreciate it. Thanks.

  • @abdullahamir3873
    @abdullahamir3873 4 ปีที่แล้ว

    How can we keep a copy behind in one of the containers

  • @Stonewolfh
    @Stonewolfh 5 ปีที่แล้ว +1

    Amazingly done! Simple, clean and efficient. Thanks for taking the time, helped me a lot.

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      I'm happy it helped! :D

  • @DEV_XO
    @DEV_XO 5 ปีที่แล้ว +2

    Amazing mate! Thanks a lot!

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      You're welcome! More to come!

  • @haniariimaukloo3892
    @haniariimaukloo3892 2 ปีที่แล้ว

    Great video but the card still disappears when i drag and drop it :( not cool

  • @chipanyanwu
    @chipanyanwu 5 ปีที่แล้ว +2

    Lol, we have the same wallpaper! Great tutorial

  • @hnlimam
    @hnlimam 4 ปีที่แล้ว

    What abour framer motion?

  • @killerwhiteshark1797
    @killerwhiteshark1797 4 ปีที่แล้ว

    Any advice for moving components? Long Story Short, when I drag a component (that uses object KVP for styles and attributes) It auto updates state and crashes saying that it cannot read type of type={field.type}. Any advice for this?

  • @pa30p42
    @pa30p42 4 ปีที่แล้ว +1

    Good day, Thanks you a lot for video, it's awesome. But I have one problem, it doesn't work in mobile or tablet version. Why?

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว

      As we use a click event listener dragging isn't a native function for it so it only works on desktop

    • @pa30p42
      @pa30p42 4 ปีที่แล้ว +1

      @@TylerPotts Is there any way to make dnd work on mobile?

  • @malihal3056
    @malihal3056 3 ปีที่แล้ว

    how do we get the card_id? or how do we access each item to set different alerts on each one?

  • @ЕВГЕНИЙЕЛИСЕЕВ-о2п
    @ЕВГЕНИЙЕЛИСЕЕВ-о2п 3 ปีที่แล้ว +1

    thank you so much!!!

  • @gabccamilo
    @gabccamilo 4 ปีที่แล้ว +1

    Awesome! Thank you very much :D

  • @jesilasharuf3947
    @jesilasharuf3947 5 ปีที่แล้ว +1

    great its helps me in the table grid

  • @Str4tegic
    @Str4tegic 5 ปีที่แล้ว +1

    very usefull video thank you dude

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      Thanks for watching! 😁

  • @blingblingcurio3683
    @blingblingcurio3683 4 ปีที่แล้ว

    Very impressive. One question. How to limit dragging at a specific area like jQuery containment?

  • @mpriya842
    @mpriya842 4 ปีที่แล้ว

    good one, i tried this, everything works good, except the card overlay, how to change the display style to block after overlaying?

  • @lamaamro9748
    @lamaamro9748 4 ปีที่แล้ว

    so helpful. thanks a lot

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd ปีที่แล้ว

    thank you

  • @coldsweat6177
    @coldsweat6177 3 ปีที่แล้ว

    I'm getting an error: e.stopPropogation is not a function

  • @manojkamble6265
    @manojkamble6265 2 ปีที่แล้ว

    Hey where can I get the source code

  • @Edu4Dev
    @Edu4Dev 4 ปีที่แล้ว

    Awesome, tks from Brazil

  • @rafaelmoura9303
    @rafaelmoura9303 4 ปีที่แล้ว

    Amazing my friend! It's is very helpful!

    • @TylerPotts
      @TylerPotts  4 ปีที่แล้ว

      Glad to hear that!

    • @manojkamble6265
      @manojkamble6265 2 ปีที่แล้ว

      Hey where I can get the source code

  • @nahaing
    @nahaing 4 ปีที่แล้ว

    it really helped mr

  • @ozodbekrahmonov4482
    @ozodbekrahmonov4482 3 ปีที่แล้ว

    amazing

  • @crisc.castillo979
    @crisc.castillo979 4 ปีที่แล้ว

    Thank you so much you made a great tutorial!

  • @robotplant5260
    @robotplant5260 5 ปีที่แล้ว +1

    Thank you for making this tutorial.

  • @codeblooded6760
    @codeblooded6760 4 ปีที่แล้ว

    How can we make conditional drag and drop? How to avoid draggable components to drop into droppable area based on existing components in droppable area.

  • @adamwoolf9993
    @adamwoolf9993 3 ปีที่แล้ว

    awesome.

  • @waqas8333
    @waqas8333 3 ปีที่แล้ว

    what a intro ooooooooooooooooooooooooooooooooooooooooooooooooooo

  • @megharaikar8210
    @megharaikar8210 4 ปีที่แล้ว

    @Tyler Potts This really amazing . One help, unable to name the boards .

  • @fayyazkarim8822
    @fayyazkarim8822 4 ปีที่แล้ว +1

    Great, Very Helpfull

  • @bikramchettri9405
    @bikramchettri9405 5 ปีที่แล้ว +2

    Oh man I'm hook on your videos.

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว +1

      That's awesome! I am happy you're enjoying them.

    • @bikramchettri9405
      @bikramchettri9405 5 ปีที่แล้ว +2

      @@TylerPotts Hey i created calendar watching your video. Can you also implement touch events in the previous javascript drag
      & drop? codepen.io/bikram-chettri/pen/VoMJoe

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      You can but I believe you will need a library for native touch events... I believe the drag n drop api supports mobile devices.

  • @andrelevywinnikes7574
    @andrelevywinnikes7574 5 ปีที่แล้ว +1

    How can I put the elements in the order I drag?

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      You would have to set a weight on the cards and display them by weight.

  • @adilbekbaktiyar6319
    @adilbekbaktiyar6319 5 ปีที่แล้ว +2

    how to drag and drop within on board?

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      Sorry I am not sure what you mean?

    • @bencebabud7280
      @bencebabud7280 5 ปีที่แล้ว +1

      @@TylerPotts i assume he means to drag and move around on one board

    • @stevo800
      @stevo800 4 ปีที่แล้ว

      @@TylerPotts Is there a solution to this? I am still looking to get drag and drop working, but on one board. It will disappear as it is.

  • @argeelearner3978
    @argeelearner3978 5 ปีที่แล้ว

    Thanks for sharing

  • @versatilegeniuses9374
    @versatilegeniuses9374 3 ปีที่แล้ว

    Just give me the wallpaper ! It super cool

  • @techwithkaran6412
    @techwithkaran6412 3 ปีที่แล้ว

    How we can save the board??? so if we re load it still remains there

    • @TylerPotts
      @TylerPotts  3 ปีที่แล้ว

      You could use firebase to save the current position and board of each card!

    • @techwithkaran6412
      @techwithkaran6412 3 ปีที่แล้ว

      @@TylerPotts but how??

  • @anirudhkumaran83
    @anirudhkumaran83 5 ปีที่แล้ว +1

    can u pls give me any idea on how to make copy/clone drag and drop ?

    • @TylerPotts
      @TylerPotts  5 ปีที่แล้ว

      You need to get the data information instead of transfering the element, hope that helps it is a little hard to explain over comments.

  • @hichamtribak1944
    @hichamtribak1944 4 ปีที่แล้ว

    You are genius. When we drag a drop a card identically over another one the second card disappear (deleted from the board). How can we resolve this problem please? Thank you in advance.

    • @papawei
      @papawei 4 ปีที่แล้ว +2

      comment the setTimeOut part

    • @mohamedalimezghani9747
      @mohamedalimezghani9747 3 ปีที่แล้ว +1

      @@papawei i was looking for that fix, thanks !

  • @jigarsharma5196
    @jigarsharma5196 2 ปีที่แล้ว

    I want the source code... please send me the git link

  • @fabiobarros8950
    @fabiobarros8950 4 ปีที่แล้ว +1

    Muito bom cara, parabéns!!!!

  • @valentinmorales6574
    @valentinmorales6574 4 ปีที่แล้ว

    Cant drop the boxes anywhere, i can drag them but when i release them they disappear

    • @mpriya842
      @mpriya842 4 ปีที่แล้ว

      if there is no console error, it would work perfectly, may be check this line in board.js.
      const cardId = e.dataTransfer.getData('cardId');
      const card = document.getElementById(cardId);
      card.style.display = 'block';
      e.target.appendChild(card);
      make sure the camelCases areentered correctly

  • @zanarkantube
    @zanarkantube 4 ปีที่แล้ว

    Hi nice tutorial, how do i make this sortable?

  • @SunnySingh-ie8ti
    @SunnySingh-ie8ti 4 ปีที่แล้ว

    i am getting problem in drag and drop

  • @abeechr
    @abeechr 4 ปีที่แล้ว

    cool but no github link?

  • @lilithfirefly3727
    @lilithfirefly3727 4 ปีที่แล้ว

    perfect ^^

  • @SunnySingh-ie8ti
    @SunnySingh-ie8ti 4 ปีที่แล้ว +1

    share your git link

  • @MuhammadAli-vy8nr
    @MuhammadAli-vy8nr 4 ปีที่แล้ว

    hi tyler ,how i can drag multiple items to a dropable area. please guide i am using it in my project...

  • @kamil4398
    @kamil4398 2 ปีที่แล้ว

    This code does not work :(

  • @sammaiti242
    @sammaiti242 2 ปีที่แล้ว

    Ok but why did u jump

  • @samsungauxiliary5050
    @samsungauxiliary5050 2 ปีที่แล้ว

    02:55

  • @ajronn4621
    @ajronn4621 4 ปีที่แล้ว

    using getElementById in React is anti-patern!

  • @sayantanghosh4499
    @sayantanghosh4499 2 ปีที่แล้ว

    hagu

  • @ziat1988
    @ziat1988 2 ปีที่แล้ว

    document.getElementById seems to me not the reactjs' philosophy