Skip to content

Commit 7115e36

Browse files
committed
Update examples
1 parent b86509a commit 7115e36

File tree

11 files changed

+25
-67
lines changed

11 files changed

+25
-67
lines changed

examples/animations/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react/addons';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link } from 'react-router';
43

54
var { CSSTransitionGroup } = React.addons;
@@ -44,10 +43,8 @@ var Page2 = React.createClass({
4443
}
4544
});
4645

47-
var history = createHistory();
48-
4946
React.render((
50-
<Router history={history}>
47+
<Router>
5148
<Route path="/" component={App}>
5249
<Route path="page1" component={Page1} />
5350
<Route path="page2" component={Page2} />

examples/auth-flow/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { findDOMNode } from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link, Navigation } from 'react-router';
43
import auth from './auth';
54

@@ -119,10 +118,8 @@ function requireAuth(nextState, redirectTo) {
119118
redirectTo('/login', null, { nextPathname: nextState.location.pathname });
120119
}
121120

122-
var history = createHistory();
123-
124121
React.render((
125-
<Router history={history}>
122+
<Router>
126123
<Route path="/" component={App}>
127124
<Route path="login" component={Login} />
128125
<Route path="logout" component={Logout} />

examples/dynamic-segments/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link, Redirect } from 'react-router';
43

54
var App = React.createClass({
@@ -46,10 +45,8 @@ var Task = React.createClass({
4645
}
4746
});
4847

49-
var history = createHistory();
50-
5148
React.render((
52-
<Router history={history}>
49+
<Router>
5350
<Route path="/" component={App}>
5451
<Route path="user/:userID" component={User}>
5552
<Route path="tasks/:taskID" component={Task} />

examples/huge-apps/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router } from 'react-router';
43
import stubbedCourses from './stubs/COURSES';
54

@@ -18,8 +17,6 @@ var rootRoute = {
1817
]
1918
};
2019

21-
var history = createHistory();
22-
2320
React.render((
24-
<Router history={history} routes={rootRoute} />
21+
<Router routes={rootRoute} />
2522
), document.getElementById('example'));

examples/master-detail/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { findDOMNode } from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Navigation, Route, Link } from 'react-router';
43
import ContactStore from './ContactStore';
54

@@ -149,10 +148,8 @@ var NotFound = React.createClass({
149148
}
150149
});
151150

152-
var history = createHistory();
153-
154151
React.render((
155-
<Router history={history}>
152+
<Router>
156153
<Route component={App}>
157154
<Route path="/" component={Index} />
158155
<Route path="contact/new" component={NewContact} />

examples/passing-props-to-children/app.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link, Navigation } from 'react-router';
43

54
var App = React.createClass({
65
mixins: [ Navigation ],
76

8-
getInitialState: function () {
7+
getInitialState() {
98
return {
109
tacos: [
1110
{ name: 'duck confit' },
@@ -15,22 +14,23 @@ var App = React.createClass({
1514
};
1615
},
1716

18-
addTaco: function () {
17+
addTaco() {
1918
var name = prompt('taco name?');
19+
2020
this.setState({
2121
tacos: this.state.tacos.concat({name: name})
2222
});
2323
},
2424

25-
handleRemoveTaco: function (removedTaco) {
25+
handleRemoveTaco(removedTaco) {
2626
var tacos = this.state.tacos.filter(function (taco) {
2727
return taco.name != removedTaco;
2828
});
2929
this.setState({tacos: tacos});
3030
this.transitionTo('/');
3131
},
3232

33-
render: function () {
33+
render() {
3434
var links = this.state.tacos.map(function (taco, i) {
3535
return (
3636
<li key={i}>
@@ -55,11 +55,11 @@ var App = React.createClass({
5555
});
5656

5757
var Taco = React.createClass({
58-
remove: function () {
58+
remove() {
5959
this.props.onRemoveTaco(this.props.params.name);
6060
},
6161

62-
render: function () {
62+
render() {
6363
return (
6464
<div className="Taco">
6565
<h1>{this.props.params.name}</h1>
@@ -69,10 +69,8 @@ var Taco = React.createClass({
6969
}
7070
});
7171

72-
var history = createHistory();
73-
7472
React.render((
75-
<Router history={history}>
73+
<Router>
7674
<Route path="/" component={App}>
7775
<Route path="taco/:name" component={Taco} />
7876
</Route>

examples/pinterest/app.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Link } from 'react-router';
43

54
var pictures = [
@@ -112,21 +111,19 @@ var RootRoute = {
112111
component: App,
113112
indexRoute: FeedRoute,
114113

115-
getChildRoutes (location, cb) {
114+
getChildRoutes (location, callback) {
116115
var { state } = location;
117116

118117
if (state && state.fromFeed) {
119-
cb(null, [ FeedRoute ]);
118+
callback(null, [ FeedRoute ]);
120119
} else {
121-
cb(null, [ PictureRoute ]);
120+
callback(null, [ PictureRoute ]);
122121
}
123122
}
124123
};
125124

126-
var history = createHistory();
127-
128125
React.render(
129-
<Router history={history} children={RootRoute} />,
126+
<Router children={RootRoute} />,
130127
document.getElementById('example')
131128
);
132129

examples/query-params/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link } from 'react-router';
43

54
var User = React.createClass({
@@ -31,10 +30,8 @@ var App = React.createClass({
3130
}
3231
});
3332

34-
var history = createHistory();
35-
3633
React.render((
37-
<Router history={history}>
34+
<Router>
3835
<Route path="/" component={App}>
3936
<Route path="user/:userID" component={User} />
4037
</Route>

examples/shared-root/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link } from 'react-router';
43

54
var App = React.createClass({
@@ -69,10 +68,8 @@ var ForgotPassword = React.createClass({
6968
}
7069
});
7170

72-
var history = createHistory();
73-
7471
React.render((
75-
<Router history={history}>
72+
<Router>
7673
<Route path="/" component={App}>
7774
<Route component={SignedOut}>
7875
<Route path="signin" component={SignIn} />

examples/sidebar/app.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import createHistory from 'history/lib/createHashHistory';
32
import { Router, Route, Link } from 'react-router';
43
import data from './data';
54

@@ -95,10 +94,8 @@ var App = React.createClass({
9594
}
9695
});
9796

98-
var history = createHistory();
99-
10097
React.render((
101-
<Router history={history}>
98+
<Router>
10299
<Route path="/" component={App}>
103100
<Route path="category/:category" components={{content: Category, sidebar: CategorySidebar}}>
104101
<Route path=":item" component={Item} />

0 commit comments

Comments
 (0)