React-native-windows: 'Question: File drag and drop'

Created on 13 May 2020  路  5Comments  路  Source: microsoft/react-native-windows

Looking for some advice on how to implement file drag/drop from the desktop into the RNW app.

In our prior app version with Electron and ReactXP, we were using a View component that had various onDrag* methods that yielded a DataTransfer type result to process dropped files.

After looking through the React Native and your documentation, plus some searching I was not able to find a clear path forward here. Any tip in the right direction is much appreciated.

question

All 5 comments

We don't have any immediate plans to build a file drag and drop solution, but you could write a custom view manager and do it there.

@harinikmsft can you track down a knowledgeable person about drag and drop to provide direction here?

Any luck finding someone?

As it turns out, adding drag and drop support (at least a basic version) is quite easy! I've uploaded an example project here https://github.com/dstaley/react-native-windows-drag-drop-sample

This particular example only handles text files, but it should provide most of what you need to at least get started adding support.

Excellent, thank you for sharing. I'll give it a go next week!

Thanks @dstaley for the sample.

Was this page helpful?
0 / 5 - 0 ratings