Viet Phan
Viet Phan

Reputation: 2119

ReactJS: drag and drop between multiple lists

I'm newbie in ReactJS. I'm having a component similar like this:

<Section/>
   <Lesson/>
   <Lesson/>
   <Lesson/>
<Section/>
   <Lesson/>
   <Lesson/>
<Section/>
   <Lesson/>
   <Lesson/>
   <Lesson/>

How can I drag and drop Lesson among these Sections? I found a library help with this: https://github.com/bevacqua/react-dragula, but I'm a little bit confused of ref Section ReactDOM

Upvotes: 1

Views: 2042

Answers (1)

luboskrnac
luboskrnac

Reputation: 24561

I looked at Dragula example. They are using React's feature called ref Callback Attribute.

From the documentation:

React supports a special attribute that you can attach to any component. The ref attribute can be a callback function, and this callback will be executed immediately after the component is mounted. The referenced component will be passed in as a parameter, and the callback function may use the component immediately, or save the reference for future use (or both).

Upvotes: 2

Related Questions