Using react-navigation/bottom-tabs|native
V6 I'm trying to implement deeplinks.
Currently trying on iOS and for the most part everything is working fine.
However the name of the param I'm trying to parse seems to only accept id
.
For example, I have the following linking config:
const linking = {
prefixes: ['example://', 'https://example.com'],
config: {
screens: {
Home: {
path: '',
screens: {
Site: 'places/:uid',
},
},
Map: {
path: "map",
screens: {
Site: 'places/:id',
}
}
}
}
}
Note the :uid
param for the Site screen on the Home stack.
In the component for the Site screen I have:
import { useRoute } from '@react-navigation/native'
const SiteScreen = () => {
const route = useRoute()
console.log(route)
return (...)
}
Now if i link to https://example.com/places/place-name
, it correctly navigates to the Site
screen on the Home stack and if I inspect that console.log I can see:
{
key: "Site-AlkZZQFu6LcIfAdQVHbQs",
name: "Site",
path: "/places/place-name",
params: undefined
}
However If I change the linking config to have:
screens: {
Site: 'places/:id',
},
Note the param has changed to id
.
And again I navigate to https://example.com/places/place-name
My console.log now returns:
{
key: "Site-AlkZZQFu6LcIfAdQVHbQs",
name: "Site",
path: "/places/place-name",
params: {
id: "place-name"
}
}
Does anyone know why the id
param would fill the params
but one with another name would not?
The reason I need a param with another name other than ID is that users can also navigate to that route with an ID within the app which does some different logic.