import { router } from "expo-router";
import { StyleSheet, Pressable, View, Text } from "react-native"; import { GestureDetector, Gesture } from "react-native-gesture-handler";
type NoteInputType = {
note: any;
};
export default function Note({ note }: NoteInputType) {
const noteText = note?.get("text");
const noteId = note?.id;
const link = `editnote/${noteId}`;
const singleTap = Gesture.Tap()
.maxDuration(250)
.onEnd(() => {
try {
console.log("Navigating to:", link);
router.push(link);
console.log("pushed");
} catch (error) {
console.error("Error navigating:", error, link);
}
});
const longPressGesture = Gesture.LongPress().onEnd((e, success) => {
if (success) {
console.log(`Long pressed for ${e.duration} ms!`);
}
});
return (
<GestureDetector gesture={singleTap}>
<View style={styles.note_container}>
<Text style={styles.note_text}>{noteText}</Text>
</View>
</GestureDetector>
);
}
const styles = StyleSheet.create({
note_container: {
width: "100%",
borderRadius: 12,
padding: 24,
backgroundColor: "#ffffff",
shadowColor: "#32335E",
shadowOffset: {
width: 0,
height: 3,
},
shadowOpacity: 0.2,
shadowRadius: 3.6,
elevation: 3,
},
note_text: {
fontFamily: "MontserratMedium",
// letterSpacing: 0.75,
fontSize: 14,
color: "#121719",
},
});
I am using expo 51 sdk and expo router 3.5
when i tried
<Link href={link} asChild>
<Pressable style={styles.note_container}>
<Text style={styles.note_text}>{noteText}</Text>
</Pressable>
The page is navigating to the dynamic link but when i am trying to use tap gesture to navigate it isnot working. I am getting console.log as
Navigating to: editnote/w28CQvU5Mg
ERROR Error navigating: {} editnote/w28CQvU5Mg