Skip to content

Commit 987f6aa

Browse files
committed
Merge branch 'master' into next
2 parents d88e936 + 112cce4 commit 987f6aa

File tree

40 files changed

+116
-74
lines changed

40 files changed

+116
-74
lines changed

docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Called on routes when the location changes, but the route itself neither enters
333333

334334
If `callback` is listed as a 4th argument, this hook will run asynchronously, and the transition will block until `callback` is called.
335335

336-
##### `onLeave()`
336+
##### `onLeave(prevState)`
337337
Called when a route is about to be exited.
338338

339339

docs/Glossary.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ This is a glossary of common terms used in the React Router codebase and documen
1111
* [LocationDescriptor](#locationdescriptor)
1212
* [LocationKey](#locationkey)
1313
* [LocationState](#locationstate)
14+
* [Params](#params)
1415
* [Path](#path)
1516
* [Pathname](#pathname)
16-
* [Params](#params)
1717
* [Query](#query)
1818
* [QueryString](#querystring)
1919
* [RedirectFunction](#redirectfunction)
@@ -66,10 +66,10 @@ A *hash* is a string that represents the hash portion of the URL. It is synonymo
6666
## LeaveHook
6767

6868
```js
69-
type LeaveHook = () => any;
69+
type LeaveHook = (prevState: RouterState) => any;
7070
```
7171

72-
A *leave hook* is a user-defined function that is called when a route is about to be unmounted.
72+
A *leave hook* is a user-defined function that is called when a route is about to be unmounted. It receives the previous [router state](#routerstate) as its first argument.
7373

7474
## Location
7575

@@ -127,6 +127,14 @@ This type gets its name from the first argument to HTML5's [`pushState`][pushSta
127127
[pushState]: https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method
128128
[replaceState]: https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_replaceState()_method
129129
130+
## Params
131+
132+
```js
133+
type Params = Object;
134+
```
135+
136+
The word *params* refers to an object of key/value pairs that were parsed out of the original URL's [pathname](#pathname). The values of this object are typically strings, unless there is more than one param with the same name in which case the value is an array.
137+
130138
## Path
131139
132140
```js
@@ -143,14 +151,6 @@ type Pathname = string;
143151
144152
A *pathname* is the portion of a URL that describes a hierarchical path, including the preceding `/`. For example, in `http://example.com/the/path?the=query`, `/the/path` is the pathname. It is synonymous with `window.location.pathname` in web browsers.
145153

146-
## QueryString
147-
148-
```js
149-
type QueryString = string;
150-
```
151-
152-
A *query string* is the portion of the URL that follows the [pathname](#pathname), including any preceding `?`. For example, in `http://example.com/the/path?the=query`, `?the=query` is the query string. It is synonymous with `window.location.search` in web browsers.
153-
154154
## Query
155155

156156
```js
@@ -159,13 +159,13 @@ type Query = Object;
159159

160160
A *query* is the parsed version of a [query string](#querystring).
161161

162-
## Params
162+
## QueryString
163163

164164
```js
165-
type Params = Object;
165+
type QueryString = string;
166166
```
167167

168-
The word *params* refers to an object of key/value pairs that were parsed out of the original URL's [pathname](#pathname). The values of this object are typically strings, unless there is more than one param with the same name in which case the value is an array.
168+
A *query string* is the portion of the URL that follows the [pathname](#pathname), including any preceding `?`. For example, in `http://example.com/the/path?the=query`, `?the=query` is the query string. It is synonymous with `window.location.search` in web browsers.
169169

170170
## RedirectFunction
171171

@@ -204,6 +204,8 @@ The term *route component* refers to a [component](#component) that is directly
204204
- `route` – The [route](#route) that declared this component
205205
- `routeParams` – A subset of the [params](#params) that were specified in the route's [`path`](#routepattern)
206206
207+
Route components should generally be component classes rather than strings. This will avoid potential issues with passing the injected props above to DOM components.
208+
207209
## RouteConfig
208210
209211
```js

docs/guides/RouteConfiguration.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ URL | Components
106106

107107
### Decoupling the UI from the URL
108108

109-
It would be nice if we could remove the `/inbox` segment from the `/inbox/messages/:id` URL pattern, but still render `Message` nested inside the `App -> Inbox` UI. Absolute `path`s let us do exactly that.
109+
It would be nice if we could remove the `/inbox` segment from the `/inbox/messages/:id` URL pattern, but still render `Message` nested inside the `App -> Inbox` UI. Pathless routes let us do exactly that.
110110

111111
```js
112112
render((
@@ -125,7 +125,7 @@ render((
125125
), document.body)
126126
```
127127

128-
The ability to use absolute paths in deeply nested routes gives us complete control over what the URL looks like! We don't have to add more segments to the URL just to get nested UI.
128+
The ability to use declare routes without paths gives us complete control over what the URL looks like! We don't have to add more segments to the URL just to get nested UI.
129129

130130
We can now render the following URLs:
131131

@@ -136,8 +136,6 @@ URL | Components
136136
`/inbox` | `App -> Inbox`
137137
`/messages/:id` | `App -> Inbox -> Message`
138138

139-
**Note**: Absolute paths may not be used in route config that is [dynamically loaded](/docs/guides/DynamicRouting.md).
140-
141139
### Preserving URLs
142140

143141
Wait a minute ... we just changed a URL! [That's not cool](http://www.w3.org/Provider/Style/URI.html). Now everyone who had a link to `/inbox/messages/5` has a **broken link**. :(
@@ -184,7 +182,7 @@ Continuing with our example above, if a user clicked on a link to `/about` from
184182

185183
Since [routes](/docs/Glossary.md#route) are usually nested, it's useful to use a concise nested syntax like [JSX](https://facebook.github.io/jsx/) to describe their relationship to one another. However, you may also use an array of plain [route](/docs/Glossary.md#route) objects if you prefer to avoid using JSX.
186184

187-
The `<Redirect>` configuration helper is not available when using plain routes, so you have to set up the redirect using the `onEnter` hook.
185+
The `<Redirect>` configuration helper is not available when using plain routes, so you have to set up the redirect using the `onEnter` hook.
188186

189187
The route config we've discussed up to this point could also be specified like this:
190188

examples/active-links/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react'
22
import { render } from 'react-dom'
33
import { Router, Route, IndexRoute, Link, IndexLink, browserHistory } from 'react-router'
44

5+
import withExampleBasename from '../withExampleBasename'
6+
57
const ACTIVE = { color: 'red' }
68

79
const App = ({ children }) => (
@@ -57,7 +59,7 @@ const About = () => (
5759
)
5860

5961
render((
60-
<Router history={browserHistory}>
62+
<Router history={withExampleBasename(browserHistory, __dirname)}>
6163
<Route path="/" component={App}>
6264
<IndexRoute component={Index}/>
6365
<Route path="/about" component={About}/>

examples/active-links/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<!doctype html public "restroom">
22
<title>Active Links Example</title>
3-
<base href="/active-links"/>
43
<link href="/global.css" rel="stylesheet"/>
54
<body>
65
<h1 class="breadcrumbs"><a href="/">React Router Examples</a> / Active Links</h1>

examples/animations/app.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react'
2-
import { render } from 'react-dom'
32
import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
3+
import { render } from 'react-dom'
44
import { browserHistory, Router, Route, IndexRoute, Link } from 'react-router'
5+
6+
import withExampleBasename from '../withExampleBasename'
7+
58
import './app.css'
69

710
const App = ({ children, location }) => (
@@ -46,7 +49,7 @@ const Page2 = () => (
4649
)
4750

4851
render((
49-
<Router history={browserHistory}>
52+
<Router history={withExampleBasename(browserHistory, __dirname)}>
5053
<Route path="/" component={App}>
5154
<IndexRoute component={Index}/>
5255
<Route path="page1" component={Page1} />

examples/animations/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<!doctype html public "restroom">
22
<title>Animation Example</title>
3-
<base href="/animations"/>
43
<link href="/global.css" rel="stylesheet"/>
54
<link href="/animations/app.css" rel="stylesheet"/>
65
<body>

examples/auth-flow-async-with-query-params/app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { createClass } from 'react'
22
import { render } from 'react-dom'
3-
import {
4-
Router, Route, IndexRoute, browserHistory, Link, withRouter
5-
} from 'react-router'
3+
import { Router, Route, IndexRoute, browserHistory, Link, withRouter } from 'react-router'
4+
5+
import withExampleBasename from '../withExampleBasename'
66

77
function App(props) {
88
return (
@@ -88,7 +88,7 @@ function serverAuth(authToken) {
8888
}
8989

9090
render((
91-
<Router history={browserHistory}>
91+
<Router history={withExampleBasename(browserHistory, __dirname)}>
9292
<Route path="/" component={App}>
9393
<IndexRoute component={Form} />
9494
<Route path="page" component={Page} onEnter={requireCredentials}/>

examples/auth-flow-async-with-query-params/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<base href="/auth-flow-async-with-query-params"/>
54
<meta charset="utf-8">
65
<title>Authentication with query parameters</title>
76
<link rel="stylesheet" href="/global.css"/>

examples/auth-flow/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react'
22
import { render } from 'react-dom'
33
import { browserHistory, Router, Route, Link, withRouter } from 'react-router'
4+
5+
import withExampleBasename from '../withExampleBasename'
46
import auth from './auth'
57

68
const App = React.createClass({
@@ -125,7 +127,7 @@ function requireAuth(nextState, replace) {
125127
}
126128

127129
render((
128-
<Router history={browserHistory}>
130+
<Router history={withExampleBasename(browserHistory, __dirname)}>
129131
<Route path="/" component={App}>
130132
<Route path="login" component={Login} />
131133
<Route path="logout" component={Logout} />

0 commit comments

Comments
 (0)