clauderic / dnd-kit

The modern, lightweight, performant, accessible and extensible drag & drop toolkit for React.
http://dndkit.com
MIT License
12.71k stars 632 forks source link

Automatically generate id for components #1423

Open ChurroC opened 3 months ago

ChurroC commented 3 months ago

As far as I can see each draggable or droppable component needs a unique id. But these unique id's aren't really referred to else where. So could be create a unique uiud or use react's useId to assign each components its own id.

SonuKumar145 commented 2 months ago

please explain what do you mean by But these unique id's aren't really referred to else where. in my case i used uuid to generate unique ids

omgoshjosh commented 1 month ago

@SonuKumar145 , for example if you're creating new sortable rows that don't yet have a DB id (you haven't yet created them after all), you have to generate an unique id so that the sortable list works.

here's a quote from the getting started quick start page on the docs:

The useDroppable hook isn't opinionated about how your app should be structured. At minimum though, it requires you pass a ref to the DOM element that you would like to become droppable. You'll also need to provide a unique id attribute to all your droppable components.