react-native-reorderable-list
Version:
Reorderable list for React Native applications, powered by Reanimated
19 lines (15 loc) • 480 B
text/typescript
import {useAnimatedReaction} from 'react-native-reanimated';
import {useContext} from './useContext';
import {ReorderableCellContext} from '../contexts';
export const useReorderableDragStart = (onStart: (index: number) => void) => {
const {draggedIndex, index} = useContext(ReorderableCellContext);
useAnimatedReaction(
() => draggedIndex.value === index,
newValue => {
if (newValue && onStart) {
onStart(index);
}
},
[onStart],
);
};