mgcrea / react-native-dnd

Modern and easy-to-use drag&drop library for react-native.
https://mgcrea.github.io/react-native-dnd/
MIT License
135 stars 12 forks source link

Expose the droppableActiveId as meta property in onUpdate event #19

Open djleven opened 4 months ago

djleven commented 4 months ago

Hello Olivier,

First of all, thank you for the wonderful contribution that is react-native-dnd.

I needed to access the active droppable Id during drag operations, ideally from the dndPovider. The onDragEnd event provides us with this at the end of the drag process, but I could not find a way to get the id before. The reason was to manipulate some data unrelated to styling the components (which is already easily doable with useAnimatedStyle).

I struggled with a few approaches trying to get it from within my droppable component using useActiveDropReaction and useLatestValue (and even 'hacking' the useAnimatedStyle) in combination with runOnJs. But they all proved too heavy and costly. Turning to the dndPovider and exposing the id that was already there seemed the cleanest way to go.

It seems to me this could potentiality be a desired feature for many drag and drop type use cases and implementations. Please let me know if I missed something.

Thanks, Kostas

mgcrea commented 4 months ago

Hey! Any reason you closed it? Was busy the last few days but happy to merge contributions to the project! Thanks for the PR!

djleven commented 3 months ago

Hi Olivier!

Apologies for the late reply, I just saw this now.

I had some second thoughts about how useful this might actually be and ended up closing it.

I would be happy to look at fixing the failing tests this weekend if you still want to merge it.

Thanks!