Sortable List
DraxList is the fastest way to add drag-to-reorder to a list. It wraps any list component (FlatList, FlashList, LegendList) with full reorder support.
Basic Usage
import { useState } from 'react';
import { Text, View } from 'react-native';
import { DraxProvider, DraxList } from 'react-native-drax';
function App() {
const [items, setItems] = useState(['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry']);
return (
<DraxProvider>
<DraxList
data={items}
keyExtractor={(item) => item}
onReorder={({ data }) => setItems(data)}
renderItem={({ item }) => (
<View style={{ padding: 16, backgroundColor: '#f5f5f5', marginVertical: 2 }}>
<Text>{item}</Text>
</View>
)}
/>
</DraxProvider>
);
}
Long-press any item to start dragging. Items shift to make room. Release to drop.
Using with FlashList
Pass any list component via the component prop:
import { FlashList } from '@shopify/flash-list';
<DraxList
component={FlashList}
data={items}
keyExtractor={(item) => item.id}
onReorder={({ data }) => setItems(data)}
renderItem={({ item }) => <ItemCard item={item} />}
estimatedItemSize={60}
/>
Extra props like estimatedItemSize are forwarded to the underlying list component.