react-navigation.github.io
react-navigation.github.io copied to clipboard
Incomplete documentation on optional parameters with deep linking and path
Current Behavior
According to tutorials and documentation I managed to gather online, this piece of code should allow for an optional parameter param2
, but it seems that it doesn't work and the path is never matched.
ex: {
screen: Screen,
},
path: "ex/:param1(/:param2)",
},```
### Expected Behavior
I hoped here that different paths would be matched like:
- app://ex/p1
- app://ex/p1/p2
Both paths should have been matched according to my understanding of the `path` keyword (almost absent from the documentation, hence the issue).
### Your Environment
| software | version
| ---------------- | -------
| react-navigation | 4.0.10
| react-native | 0.61.3
| node | n/a
| npm or yarn | n/a
As ex
is also used for resolving the path, it seems that doubling the entry doesn't work either.
So it would be really great t solve this problem.
Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.
Yes, the problem is still present!
Come on, it's not stale or done!
Still not close...
I need this as well. Is there any plan to support optional params within deep linking paths?
You can make params optional, it's in the docs https://reactnavigation.org/docs/configuring-links/#marking-params-as-optional
Link above to the docs didn't navigate to the #id of the page so here is the code sample from the docs for easier reference.
path: 'user/:id/:section?'
add ?
to make it optional.