@@ -16,7 +16,7 @@ npm install --save react-with-params
16
16
import Route from ' react-router/Route'
17
17
import {withParams } from ' react-with-params'
18
18
19
- const ShowName = withParams (' name' , { match: ' /user/:name' })(({name }) =>
19
+ const ShowName = withParams ({params: ' name' , match: ' /user/:name' })(({name }) =>
20
20
<span >{name }< / span >
21
21
)
22
22
@@ -27,13 +27,42 @@ const ShowName = withParams('name', {match: '/user/:name'})(({name}) =>
27
27
import Route from ' react-router/Route'
28
28
import {withParams } from ' react-with-params'
29
29
30
- const ShowNameAndId = withParams ([' name' , ' id' ], { match: ' /user/:name/:id' })(({name , id }) =>
30
+ const ShowNameAndId = withParams ({params: [' name' , ' id' ], match: ' /user/:name/:id' })(({name , id }) =>
31
31
<span >{id } - {name }< / span >
32
32
)
33
33
34
34
< Route exact path = ' /user/:name/:id' component = {ShowNameAndId } / >
35
35
```
36
36
37
+ ### Query parameters
38
+ ``` typescript
39
+ import Route from ' react-router/Route'
40
+ import {withParams } from ' react-with-params'
41
+
42
+ const Display = withParams ({
43
+ queryParams: ' next' ,
44
+ match: ' /users' ,
45
+ })(({next }) =>
46
+ <span >{next }< / span >
47
+ )
48
+
49
+ < Route exact path = ' /users' component = {Display } / >
50
+ ```
51
+
52
+ ``` typescript
53
+ import Route from ' react-router/Route'
54
+ import {withParams } from ' react-with-params'
55
+
56
+ const Display = withParams ({
57
+ queryParams: [' next' , ' timestamp' ],
58
+ match: ' /users' ,
59
+ })(({next , timestamp }) =>
60
+ <span >{next } - {timestamp }< / span >
61
+ )
62
+
63
+ < Route exact path = ' /users' component = {Display } / >
64
+ ```
65
+
37
66
## License
38
67
react-with-params is dual-licensed under Apache 2.0 and MIT
39
68
terms.
0 commit comments