Skip to content

Commit 6e23feb

Browse files
committed
Update 0 Overview.md
moved the history declaration outside of the `render` function.
1 parent 944cbdd commit 6e23feb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/00 Guides/0 Overview.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ var App = React.createClass({
138138
}
139139
});
140140

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

155158
```js
159+
var history = new HashHistory();
156160
var routes = {
157161
path: '/',
158162
component: App,
@@ -162,7 +166,7 @@ var routes = {
162166
]
163167
};
164168

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

168172
Adding more UI
@@ -190,8 +194,9 @@ var Inbox = React.createClass({
190194
}
191195
});
192196

197+
var history = new HashHistory();
193198
React.render((
194-
<Router history={new HashHistory}>
199+
<Router history={history}>
195200
<Route component={App}>
196201
<Route path="about" component={About}/>
197202
<Route path="inbox" component={Inbox}>

0 commit comments

Comments
 (0)