Skip to content

Commit 29155fc

Browse files
h-destimdorr
authored andcommittedApr 14, 2019
Update matchPath docs (#6703)
* Update matchPath.md * Update matchPath.md * Update matchPath.md
1 parent 3ccbd19 commit 29155fc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
 

‎packages/react-router/docs/api/matchPath.md

+31
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,34 @@ to the matching props `Route` accepts:
2929
exact; // optional, defaults to false
3030
}
3131
```
32+
33+
## returns
34+
35+
It returns an object when provided pathname does match `path` prop or `null` otherwise.
36+
37+
```
38+
matchPath("/users/2", {
39+
path: "/users/:id",
40+
exact: true,
41+
strict: true
42+
})
43+
44+
// {
45+
// isExact: true
46+
// params: {
47+
// id: "2"
48+
// }
49+
// path: "/users/:id"
50+
// url: "/users/2"
51+
// }
52+
```
53+
54+
```
55+
matchPath("/users", {
56+
path: "/users/:id",
57+
exact: true,
58+
strict: true
59+
})
60+
61+
// null
62+
```

0 commit comments

Comments
 (0)
Please sign in to comment.