I'm working with react-navigation and I'm trying to configure my linking element because I need it to use it in apps and web to. It works fine with simple URLs but I don't know how exactly include a URL with query params.
My URL is /ecare/page?reference=XXX
and here's my linking
const linking = {
prefixes: ['//my-prefix'],
config: {
screens: {
Invoices: 'ecare/invoices',
Products: {
path: 'ecare/page/:reference',
}
}
},
}
How can I exactly parser my URL from my query param URL to my linking working fine?
A late answer but it might help someone. I've also spent some time on this issue. Here's what I was missing.
Keys in the screens object correspond with the screen name.
So if you have the following screen:
<SomeScreen name={'invoices'} ... />
And you want to navigate to it with the following
const navigationProps = useLinkProps({
to: {
screen: 'invoices',
params: { reference: someValue },
},
})
Then you have to specify your screen in the linking config as:
const linking = {
prefixes: ['//my-prefix'],
config: {
screens: {
['invoices']: 'invoices/:reference'
}
},
}
Not as Invoices: 'invoices/:reference'
So,
Key == Screen name
Path == any value you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With