mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
Currently, if we don't have matching routes for a path, we'll reuse the path name for the route name. This doesn't produce an error, and renders the initial route in the navigator. However, the user doesn't have a way of handling this with the default configuration.
This PR adds support for a wildcard pattern ('*'). The wildcard pattern will be matched after all other patterns were matched and will always match unmatched screens. This allows the user to implement a 404 screen.
Example:
```js
{
Home: '',
Profile: 'user/:id',
404: '*',
}
```
This config will return the `404` route for paths which didn't match `Home` or `Profile`, e.g. - `/test`
Closes #8019
Co-authored-by: Evan Bacon <baconbrix@gmail.com>
Example for React Navigation
If you want to run the example from the repo,
- Clone the repository and run
yarnin the project root - Run
yarn example startto start the packager - Follow the instructions to open it with the Expo app
You can also run the currently published app on Expo on your Android device or iOS simulator or the web app in your browser.