You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-router-website/modules/api/Route.md
+24-13Lines changed: 24 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -110,26 +110,37 @@ Routes without a `path` _always_ match.
110
110
111
111
When `true`, will only match if the path matches the `location.pathname`_exactly_.
112
112
113
-
| path | location.pathname | exact | matches? |
114
-
|---|---|---|---|---|
115
-
|`/one`|`/one/two`|`true`| no |
116
-
|`/one`|`/one/two`|`false`| yes |
117
-
118
113
```js
119
114
<Route exact path="/one" component={About}/>
120
115
```
121
116
117
+
| path | location.pathname | exact | matches? |
118
+
|---|---|---|---|---|
119
+
|`/one`|`/one/two`|`true`| no |
120
+
|`/one`|`/one/two`|`false`| yes |
121
+
122
122
## strict: bool _`<Route>`_ {id=route.strict}
123
123
124
-
When `true`, enforces strict matching of trailing slashes on`location.pathname`.
124
+
When `true`, a `path` that has a trailing slash will only match a `location.pathname` with a trailing slash. This has no effect when there are additional URL segments in the`location.pathname`.
125
125
126
-
| path | location.pathname | strict | matches? |
127
-
|---|---|---|---|---|
128
-
|`/one/two`|`/one/two/`|`false`| yes |
129
-
|`/one/two`|`/one/two/`|`true`| no |
130
-
|`/one/two/`|`/one/two/`|`false`| yes |
131
-
|`/one/two/`|`/one/two/`|`true`| yes |
126
+
```js
127
+
<Route strict path="/one/" component={About}/>
128
+
```
129
+
130
+
| path | location.pathname | matches? |
131
+
| --- | --- | --- |
132
+
|`/one/`|`/one`| no |
133
+
|`/one/`|`/one/`| yes |
134
+
|`/one/`|`/one/two`| yes |
135
+
136
+
**NOTE:**`strict` can be used to enforce that a `location.pathname` has no trailing slash, but in order to do this both `strict` and `exact` must be `true`.
0 commit comments