How to add new items #101
Replies: 2 comments 5 replies
-
@pbalasimonsngular Hey there! Here's a little repo I spun up showing how to use both the
If you would like to reuse your existing state and pass that to the drag-and-drop, use the Let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
Hi @sashamilenkovic again, After two days of testing your response and making progress in my development, I can say that your first example using useDragAndDrop works perfectly. However, after updating my array, I encountered another warning that I cannot understand. Here is my code:
As you can see, this is my list of products. At the end of the list, I have a container that loads more products when it appears in the viewport (I want to do a infinite scroll). It works, but I receive the following message in the browser: The number of enabled nodes does not match the number of values. However, if I add the new products through an onClick event of a button, it works fine without displaying this message. Do you know what is the problem, or what can I do to avoid this message? I would like to update the list with inifinite scroll. Thanks you so much! |
Beta Was this translation helpful? Give feedback.
-
Hi @sashamilenkovic and all,
I’m developing an app in Next.js using the drag-and-drop plugin (v0.1.5), but I’m encountering an issue when trying to dynamically update the list of draggable items.
My goal is to add, delete, and update items in the list that I want to drag. However, I’m unable to achieve this functionality properly.
Here’s a simplified version of my code:
When I click the "ADD NEW ITEM" button, I expect the new element to appear in the list and be draggable, but it seems like the useDragAndDrop hook only initializes the drag-and-drop functionality once (on the first render) and doesn’t update when the list changes.
Is there a specific way to make the hook reinitialize or handle updates to the list dynamically?
Any guidance on how to achieve this would be greatly appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions