Skip to content

Commit cd74bbd

Browse files
committed
add docs about query params in links
1 parent 5be6cf9 commit cd74bbd

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

README.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,34 @@ Route({handler: App},
231231

232232
Paths are not inherited from parent routes.
233233

234+
### Link (Component)
235+
236+
Creates an anchor tag that links to a route in the application. Also
237+
gets the `active` class automatically when the route matches. If you
238+
change the path of your route, you don't have to change your links.
239+
240+
#### Properties
241+
242+
**to** - The name of the route to link to.
243+
244+
**query** - Object, Query parameters to add to the link. Access query
245+
parameters in your route handler with `this.props.query`.
246+
247+
**[param]** - Any parameters the route defines are passed by name
248+
through the link's properties.
249+
250+
#### Example
251+
252+
Given a route like `<Route name="user" path="/users/:userId"/>`:
253+
254+
```xml
255+
<Link to="user" userId={user.id} params={{foo: bar}}>{user.name}</Link>
256+
<!-- becomes one of these depending on your router and if the route is
257+
active -->
258+
<a href="/users/123?foo=bar" class="active">Michael</a>
259+
<a href="#/users/123?foo=bar">Michael</a>
260+
```
261+
234262
### Handlers
235263

236264
There are some properties and hooks available to the handlers you pass
@@ -299,31 +327,6 @@ var Settings = React.createClass({
299327
});
300328
```
301329

302-
### Link (Component)
303-
304-
Creates an anchor tag that links to a route in the application. Also
305-
gets the `active` class automatically when the route matches. If you
306-
change the path of your route, you don't have to change your links.
307-
308-
#### Properties
309-
310-
**to** - The name of the route to link to.
311-
312-
**[param]** - Any parameters the route defines are passed by name
313-
through the link's properties.
314-
315-
#### Example
316-
317-
Given a route like `<Route name="user" path="/users/:userId"/>`:
318-
319-
```xml
320-
<Link to="user" userId={user.id}>{user.name}</Link>
321-
<!-- becomes one of these depending on your router and if the route is
322-
active -->
323-
<a href="/users/123" class="active">Michael</a>
324-
<a href="#/users/123">Michael</a>
325-
```
326-
327330
Development
328331
-----------
329332

0 commit comments

Comments
 (0)