ARTICLE AD BOX
I have an Expo app where I have an element. I want to call an async function when I double tap that element. For doing that, I found the react-native-gesture-handler library. I wrapped the whole component in a <GestureHandlerRootView> as the docs said, getting the code below. However, the async function editUserTask(), which is defined in another file, doesn't even run here when I double tap. Why is that? I've seen several ideas about using runOnJS(), but VS Code tells me it is deprecated. Any solutions?
// import... import { Gesture, GestureDetector, GestureHandlerRootView, } from "react-native-gesture-handler"; export default function Todo() { <GestureHandlerRootView> // ... userTasks[0]?.map((pendingUserTask, index) => { const doubleTap = Gesture.Tap() .numberOfTaps(2) .onStart(() => { async () => { await editUserTask({ id: pendingUserTask.id, title: pendingUserTask.title, description: pendingUserTask.description, deadline: pendingUserTask.deadline.toDate(), user_id: pendingUserTask.user_id as never, done: true, tags: pendingUserTask.tags, }); console.log("A"); }; }); return ( <GestureDetector key={`pending-${index}`} gesture={doubleTap}> <View collapsable={false}> <TaskElement userTask={pendingUserTask} fetchTasksFunction={fetchUserTasks} openTaskModalFunction={openTaskModal} /> </View> </GestureDetector> </GestureHandlerRootView> }14.5k9 gold badges84 silver badges133 bronze badges
New contributor
davidcm-dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
