英文:
How can I create an interactive list with drag-and-drop functionality in React Native with Expo Go?
问题
我正在寻求在我的React Native应用中实现一个列表,允许用户通过拖动上下移动项目来有效地改变列表的顺序。我尝试了几个npm包,但似乎都不起作用,或者不适用于最新的版本。有人可以建议一种在React Native中使用Expo Go创建可拖动列表的方法吗?我尝试了不同的方法,但还没有找到解决方法。任何帮助将不胜感激。谢谢!
英文:
I'm looking to implement a list in my React Native app that allows users to rearrange items by dragging them up and down, effectively changing the order of the list. I've tried several npm packages, but none seem to work or are outdated for the latest versions. Can anyone suggest a way to create a draggable list in React Native with Expo Go? I've tried different approaches, but haven't been able to figure it out. Any help would be appreciated. Thanks!
答案1
得分: 1
你可以尝试使用 react-native-draglist
:https://github.com/fivecar/react-native-draglist
这个包是react-native-draggable-flatlist
的基本版本,除了react
和react-native
之外没有任何依赖项。具体来说,它特意构建为避免使用react-native-reanimated
及其悬挂/崩溃问题。
它在以下方面存在限制:
- 它的动画不太流畅(尽管它使用了本地驱动程序)
- 它只处理垂直列表(尽管在PR中添加水平列表不难)
英文:
You can try react-native-draglist
: https://github.com/fivecar/react-native-draglist
This package is a basic version of react-native-draggable-flatlist
without dependencies on anything except react
and react-native
. Specifically, it is deliberately built to avoid react-native-reanimated
and its hanging/crashing issues.
It is limited in the following ways:
- It does not animate as smoothly (though it does useNativeDriver)
- It only handles vertical lists (though adding horizontal in a PR won't be hard)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论