react-navigation.github.io icon indicating copy to clipboard operation
react-navigation.github.io copied to clipboard

Incomplete documentation on optional parameters with deep linking and path

Open mbrucher opened this issue 4 years ago • 8 comments

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

mbrucher avatar Nov 19 '19 20:11 mbrucher

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.

mbrucher avatar Nov 22 '19 21:11 mbrucher

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.

github-actions[bot] avatar Jan 22 '20 00:01 github-actions[bot]

Yes, the problem is still present!

mbrucher avatar Jan 22 '20 19:01 mbrucher

Come on, it's not stale or done!

mbrucher avatar Jan 30 '20 07:01 mbrucher

Still not close...

mbrucher avatar Feb 07 '20 21:02 mbrucher

I need this as well. Is there any plan to support optional params within deep linking paths?

Ingibjorg avatar Mar 19 '20 23:03 Ingibjorg

You can make params optional, it's in the docs https://reactnavigation.org/docs/configuring-links/#marking-params-as-optional

michaelpomogajko avatar Nov 08 '20 19:11 michaelpomogajko

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.

foloinfo avatar Oct 13 '21 01:10 foloinfo