Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native drag and drop

I'm trying to implement drag and drop in a React Native application.

Has anyone out there used this ? Somehow I'm not able to drag the text. There are not enough steps to use the npm module.

After debugging for some time I found that onLayout & onLongPress are undefined, can anyone help me on this ?

like image 796
Rajesh Avatar asked Dec 13 '25 21:12

Rajesh


1 Answers

Assuming you're new to React Native (as am I, kind of), and you don't have an example of your code, there might be a few things going on. (and there is a high chance you already know all of these things).

Did you follow this example? Here they set onLayout and onLongPress as the props of the DraggableThing component. Next they call the component with functions (onDragItemLayout, startDragHandler) bound to these properties. These functions are supplied by importing the createDropZone, did you import everything?

If you did, importing third-party components is kind of a hassle, because most of the times you're required to do some things in xCode. Not sure if that's also the case right now, but it might be something to look into.

Also my advice would be to take a look at the module supplied in the answer above.

like image 141
Fabian Tjoe A On Avatar answered Dec 15 '25 13:12

Fabian Tjoe A On



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!