import { defaultImage } from "@/constants"
import Colors from "@/constants/Colors"
import { Product } from "@/types"
import { useRoute } from "@react-navigation/native"
import { Link, useRouter, useSegments } from "expo-router"
import { Image, Pressable, StyleSheet, Text, View } from "react-native"
type ProductListIt`emProps={
product:Product
}
const ProductListItem = ({product}:ProductListItemProps) => {
const segment=useSegments();
const seg=segment[0] || "";
return (
**<Link href={`/${seg}/menu/${product.id}`} asChild>**
<Pressable style={styles.container} >
<Image style={{width:'100%',aspectRatio:1}} source={{uri:product.image || defaultImage}} resizeMode="contain"/>
<Text style={s`tyles.title}>{product.name}</Text>
<Text style={styles.price}>{product.price}</Text>
</Pressable>
</Link>
)
}
export default ProductListItem
const styles = StyleSheet.create({
container: {
backgroundColor:'white',
padding:10,
borderRadius:20,
flex:1,
maxWidth:'50%'
},
title: {
fontSize: 20,
fontWeight: 'bold',
},
price: {
marginVertical: 5,
color:Colors.light.tint
},
});
In JSX the Link statement giving me this error Type '/${string}/menu/${number}' is not assignable to type 'StaticRoutes | RelativePathString | ${string}:${string}'.
I am using expo router
can anyone help me that why my Link is not taking the segment[0] as route