Skip to content

Commit e722d4e

Browse files
WoLewickisatya164
authored andcommitted
feat: add initialRouteName guide to use-linking.md
1 parent 2389916 commit e722d4e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

website/versioned_docs/version-5.x/use-linking.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ When a string is specified, it's equivalent to providing the `path` option.
9292

9393
The `path` option is a pattern to match against the path. Any segments starting with `:` are recognized as a param with the same name. For example `item/42` will be parsed to `{ name: 'item', params: { id: '42' } }`.
9494

95+
The `initialRouteName` option ensures that the route name passed there will be present in the state for the navigator, e.g. for config:
96+
97+
```js
98+
{
99+
Home: {
100+
initialRouteName: 'Feed',
101+
screens: {
102+
Catalog: {
103+
path: 'item/:id',
104+
parse: {
105+
id: Number,
106+
},
107+
},
108+
Feed: 'feed',
109+
},
110+
},
111+
}
112+
```
113+
114+
and URL : `/item/42`, the state will look like this:
115+
116+
```js
117+
{
118+
routes: [
119+
{
120+
name: 'Home',
121+
state: {
122+
index: 1,
123+
routes: [
124+
{
125+
name: 'Feed'
126+
},
127+
{
128+
name: 'Catalog',
129+
params: { id: 42 },
130+
},
131+
],
132+
},
133+
},
134+
],
135+
}
136+
```
137+
95138
The `parse` option controls how the params are parsed. Here, you can provide the name of the param to parse as a key, and a function which takes the string value for the param and returns a parsed value:
96139

97140
```js

0 commit comments

Comments
 (0)