Skip to content

Getting rest id [...rest].js file from link like VehicleDetails/4 #562

Answered by britisharmy
britisharmy asked this question in Q&A
Discussion options

You must be logged in to vote

I used pathname and it worked

onPress={() => { router.push({ pathname: 'VehicleDetails/[id]', params: { id: 4} }); }}

then

import { usePathname } from "expo-router";

const pathName = usePathname();
 const segments = pathName.split('/'); 
 const id = segments[2]; 
 
 alert(id);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by britisharmy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant