Skip to content

Commit 67b3aac

Browse files
committed
Changed the docs to reflect the singleton usage
1 parent 099257c commit 67b3aac

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

doc/00 Guides/0 Overview.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Let's refactor our app to use React Router.
111111
// first we import some components
112112
import { Router, Route, Link } from 'react-router';
113113
// the histories are imported separately for smaller builds
114-
import HashHistory from 'react-router/lib/HashHistory';
114+
import { history } from 'react-router/lib/HashHistory';
115115

116116
// ...
117117

@@ -138,13 +138,10 @@ var App = React.createClass({
138138
}
139139
});
140140

141-
// Declare the history outside of the `render` function.
142-
var history = new HashHistory();
143-
144141
// Finally we render a `Router` component with some `Route`s, it'll do all
145142
// the fancy routing stuff for us.
146143
React.render((
147-
<Router history={history}>
144+
<Router history={history()}>
148145
<Route path="/" component={App}>
149146
<Route path="about" component={About}/>
150147
<Route path="inbox" component={Inbox}/>
@@ -156,7 +153,6 @@ React.render((
156153
If you're not digging the JSX route config you can use plain objects:
157154

158155
```js
159-
var history = new HashHistory();
160156
var routes = {
161157
path: '/',
162158
component: App,
@@ -166,7 +162,7 @@ var routes = {
166162
]
167163
};
168164

169-
React.render(<Router history={history} children={routes}/>, document.body);
165+
React.render(<Router history={history()} children={routes}/>, document.body);
170166
```
171167

172168
Adding more UI
@@ -194,9 +190,8 @@ var Inbox = React.createClass({
194190
}
195191
});
196192

197-
var history = new HashHistory();
198193
React.render((
199-
<Router history={history}>
194+
<Router history={history()}>
200195
<Route component={App}>
201196
<Route path="about" component={About}/>
202197
<Route path="inbox" component={Inbox}>
@@ -235,4 +230,3 @@ var Message = React.createClass({
235230
That's the gist of React Router. Application UIs are boxes inside of
236231
boxes inside of boxes; now you can keep those boxes in sync with the
237232
URL.
238-

doc/03 History/0 Histories.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
an instance of one with your own options for query parsing.
44

55
```js
6-
import History from 'react-router/lib/BrowserHistory';
7-
<Router history={History}/>
6+
import { history } from 'react-router/lib/BrowserHistory';
7+
<Router history={history()}/>
88
```
99

1010
If you need to do your own query parsing:

doc/03 History/BrowserHistory.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ Example
4343

4444
```js
4545
import { Router } from 'react-router';
46-
import BrowserHistory from 'react-router/lib/BrowserHistory';
47-
var history = new BrowserHistory();
46+
import { history } from 'react-router/lib/BrowserHistory';
4847

4948
React.render((
50-
<Router history={ history }>
49+
<Router history={ history() }>
5150
{/* ... */}
5251
</Router>
5352
), document.body);
5453
```
5554

5655
[Histories]:#TODO
57-

doc/03 History/HashHistory.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ Normal usage
3333

3434
```js
3535
import { Router } from 'react-router';
36-
import HashHistory from 'react-router/lib/HashHistory';
37-
var history = new HashHistory();
36+
import { history } from 'react-router/lib/HashHistory';
3837

3938
React.render((
40-
<Router history={ history }>
39+
<Router history={history()}>
4140
{/* ... */}
4241
</Router>
4342
), document.body);
@@ -62,4 +61,3 @@ React.render((
6261
```
6362

6463
[Histories]:#TODO
65-

0 commit comments

Comments
 (0)