Skip to content

Commit e195225

Browse files
committed
Small docs tweaks
1 parent 9f9cbb4 commit e195225

File tree

11 files changed

+100
-122
lines changed

11 files changed

+100
-122
lines changed

docs/api/Location.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
API: `Location` (object)
2+
========================
3+
4+
The router uses "location" objects to determine the current state of
5+
the application and update it when needed. In a browser environment,
6+
the location represents the URL in the browser's location bar. On the
7+
server, the location is the URL path that was used in the request.
8+
9+
ReactRouter ships with several locations that make it convenient to
10+
use in many different scenarios. They are listed below.
11+
12+
| `HashLocation` | Stores the current URL in `window.location.hash`. Use this if you need to support browsers that do not support the HTML5 history API |
13+
| `HistoryLocation` | Uses the HTML5 history API to store state in clean URLs |
14+
| `RefreshLocation` | A fallback for having clean URLs in browsers that do not support the HTML5 history API by updating `window.location` whenever the route changes. The router automatically falls back to this when you try to use `HistoryLocation` in old browsers |
15+
| `StaticLocation` | A location for stateless environments (like servers) where the URL is given once |
16+
| `TestLocation` | A location that allows you to easily stub out URL history when writing tests |
17+
18+
You can also supply the router with your own location implementation. The
19+
following methods must be implemented:
20+
21+
Methods
22+
-------
23+
24+
### `addChangeListener(listener)`
25+
26+
Adds a function to the location that should be called when it changes.
27+
28+
### `removeChangeListener(listener)`
29+
30+
Stop calling the given function when the location changes.
31+
32+
### `push`
33+
34+
Called when the router is transitioning from one path to another.
35+
36+
### `replace`
37+
38+
Called when the router is replacing (not transitioning) one url with
39+
another.
40+
41+
### `pop`
42+
43+
Called when the router attempts to go back one entry in the history.
44+
45+
### `getCurrentPath`
46+
47+
Should return the current URL path, complete with query string (if applicable).
48+
This method should be ready to go immediately after setup.
49+
50+
### `toString`
51+
52+
Should return a useful string for logging and debugging.
53+
54+
History
55+
-------
56+
57+
Additionally, location objects must:
58+
59+
- Increment `ReactRouter.History.length` immediately **after** the URL changes
60+
- Decrement `ReactRouter.History.length` immediately **before** going back to the
61+
previous URL
62+
63+
Please refer to the [built-in location objects][locations] to get an idea for how this is done.
64+
65+
[locations]: /locations

docs/api/README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
React Router API
22
================
33

4-
- [`Router`](/docs/api/Router.md)
5-
64
- [`Router.run`](/docs/api/run.md)
7-
85
- [`Router.create`](/docs/api/create.md)
6+
- [`Location`](/docs/api/Location.md)
7+
- [`Transition`](/docs/api/Transition.md)
98

10-
- Components
11-
- [`DefaultRoute`](/docs/api/components/DefaultRoute.md)
9+
- Renderable Components
10+
- [`RouteHandler`](/docs/api/components/RouteHandler.md)
1211
- [`Link`](/docs/api/components/Link.md)
12+
13+
- Configuration Components
14+
- [`Route`](/docs/api/components/Route.md)
15+
- [`DefaultRoute`](/docs/api/components/DefaultRoute.md)
1316
- [`NotFoundRoute`](/docs/api/components/NotFoundRoute.md)
1417
- [`Redirect`](/docs/api/components/Redirect.md)
15-
- [`Route`](/docs/api/components/Route.md)
16-
- [`RouteHandler`](/docs/api/components/RouteHandler.md)
1718

1819
- Mixins
1920
- [`State`](/docs/api/mixins/State.md)
2021
- [`Navigation`](/docs/api/mixins/Navigation.md)
2122

22-
- Misc
23-
- [`Location`](/docs/api/misc/Location.md)
24-
- [`transition`](/docs/api/misc/transition.md)
25-
2623
Public Modules
2724
--------------
2825

docs/api/Router.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/api/misc/transition.md renamed to docs/api/Transition.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
API: `transition` (object)
1+
API: `Transition` (object)
22
==========================
33

4-
This object is sent to the [transition hooks][transition-hooks] as the
4+
A `Transition` object is sent to the [transition hooks][transition-hooks] as the
55
first argument.
66

77
Methods

docs/api/components/DefaultRoute.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
API: `DefaultRoute` (component)
22
===============================
33

4-
A `DefaultRoute` is active when the parent route's path matches exactly.
4+
A `<DefaultRoute>` is active when the parent route's path matches exactly.
55

6-
Note, this is not a `NotFoundRoute`. It is only active when the parent's
6+
Note, this is not a `<NotFoundRoute>`. It is only active when the parent's
77
route path is matched exactly.
88

99
Props
1010
-----
1111

12-
See [Route::props][routeProps]
12+
See [<Route props>][routeProps]
1313

1414
Example
1515
-------

docs/api/components/Link.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
API: `Link` (component)
22
=========================
33

4-
Creates an anchor tag that links to a route in the application. Also
5-
gets the `active` class automatically when the route matches. If you
6-
change the path of your route, you don't have to change your links.
4+
A `<Link>` renders an `<a>` tag that links to a route in the application. If
5+
you change the path of your route, you don't also have to change your links.
6+
7+
A `<Link>` also knows when the route it links to is active and automatically
8+
applies its `activeClassName` and/or `activeStyle` when it is.
79

810
Props
911
-----
@@ -14,7 +16,7 @@ The name of the route to link to, or a full URL.
1416

1517
### `params`
1618

17-
Object, the parameters to fill in the dynamic segments of your route.
19+
An object of the names/values that correspond with dynamic segments in your route path.
1820

1921
#### Example
2022

@@ -31,17 +33,15 @@ Object, the parameters to fill in the dynamic segments of your route.
3133

3234
### `query`
3335

34-
Object, Query parameters to add to the link. Access query parameters in
35-
your route handler with `this.getQuery()`.
36+
The query string parameters as a JavaScript object.
3637

3738
### `activeClassName`
3839

39-
The className a `Link` receives when its route is active. Defaults to
40-
`active`.
40+
The className a `Link` receives when its route is active. Defaults to `active`.
4141

4242
### `activeStyle`
4343

44-
Object, the styles to apply to the link element when its route is active.
44+
The styles to apply to the link element when its route is active.
4545

4646
### `onClick`
4747

docs/api/components/NotFoundRoute.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
API: `NotFoundRoute` (component)
22
===============================
33

4-
When a parent's URL partially matches, but none of the children do, a
5-
`NotFoundRoute` will be matched and its handler activated at any level
6-
of your route hierarchy.
4+
A `<NotFoundRoute>` is active when the beginning of its parent's path
5+
matches the URL but none of its siblings do. It can be found at any level
6+
of your hierarchy, allowing you to have a context-aware "not found" page.
77

88
Props
99
-----
1010

11-
See [Route::props][routeProps]
11+
See [<Route props>][routeProps]
1212

1313
Example
1414
-------

docs/api/components/Redirect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
API: `Redirect` (component)
22
===========================
33

4-
Configures a redirect for a path in your route declarations.
4+
A `<Redirect>` sets up a redirect to another route in your application.
55

66
Props
77
-----

docs/api/components/Route.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
API: `Route` (component)
22
=========================
33

4-
Configuration component to declare your application's routes and entry
5-
view hierarchy.
4+
A `<Route>` is used to declare your application's routes and entry view hierarchy.
65

76
Props
87
-----
98

109
### `name`
1110

12-
The name of the route, used in the `Link` component and the router's
13-
transition methods.
11+
The name of the route, used in the `Link` component and the router's transition methods.
1412

1513
### `path`
1614

docs/api/components/RouteHandler.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
API: `RouteHandler` (component)
22
===============================
33

4-
The component supplied to a route is called a "Route Handler". They can
5-
be rendered by the parent handler with `<RouteHandler/>`. There are
6-
some special static methods available to these components.
4+
A `<RouteHandler>` renders the handler of the route at the level of the
5+
route hierarchy in which it is used.
76

87
Static Lifecycle Methods
98
------------------------
109

11-
You can define static methods on your route handlers that will be called
12-
during route transitions.
10+
You can define some static methods on your route handlers that will be
11+
called during route transitions.
1312

1413
### `willTransitionTo(transition, params, query, callback)`
1514

@@ -18,7 +17,7 @@ abort or redirect the transition. You can pause the transition while you
1817
do some asynchonous work and call `callback(error)` when you're done, or
1918
omit the callback in your argument list and it will be called for you.
2019

21-
See also: [transition](/docs/api/misc/transition.md)
20+
See also: [Transition](/docs/api/Transition.md)
2221

2322
### `willTransitionFrom(transition, component, callback)`
2423

@@ -27,7 +26,7 @@ opportunity to abort the transition. The `component` is the current
2726
component, you'll probably need it to check its state to decide if you
2827
want to allow the transition (like form fields).
2928

30-
See also: [transition](/docs/api/misc/transition.md)
29+
See also: [Transition](/docs/api/Transition.md)
3130

3231
#### Example
3332

0 commit comments

Comments
 (0)