Skip to content

Commit 015c0f3

Browse files
pshrmnmjackson
authored andcommitted
Update description of strict (#4453)
1 parent 577ea93 commit 015c0f3

File tree

1 file changed

+24
-13
lines changed
  • packages/react-router-website/modules/api

1 file changed

+24
-13
lines changed

packages/react-router-website/modules/api/Route.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,37 @@ Routes without a `path` _always_ match.
110110

111111
When `true`, will only match if the path matches the `location.pathname` _exactly_.
112112

113-
| path | location.pathname | exact | matches? |
114-
|---|---|---|---|---|
115-
| `/one` | `/one/two` | `true` | no |
116-
| `/one` | `/one/two` | `false` | yes |
117-
118113
```js
119114
<Route exact path="/one" component={About}/>
120115
```
121116

117+
| path | location.pathname | exact | matches? |
118+
|---|---|---|---|---|
119+
| `/one` | `/one/two` | `true` | no |
120+
| `/one` | `/one/two` | `false` | yes |
121+
122122
## strict: bool _`<Route>`_ {id=route.strict}
123123

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`.
125125

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`.
132137

133138
```js
134-
<Route strict path="/one/two/" component={About}/>
139+
<Route exact strict path="/one" component={About}/>
135140
```
141+
142+
| path | location.pathname | matches? |
143+
| --- | --- | --- |
144+
| `/one` | `/one` | yes |
145+
| `/one` | `/one/` | no |
146+
| `/one` | `/one/two` | no |

0 commit comments

Comments
 (0)