Skip to content

Commit 2205695

Browse files
committed
Update partial-app-loading example
1 parent 337945e commit 2205695

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

examples/partial-app-loading/app.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
/** @jsx React.DOM */
21
var React = require('react');
32
var Router = require('react-router');
4-
var Route = Router.Route;
5-
var Routes = Router.Routes;
6-
var Link = Router.Link;
7-
var ActiveRouteHandler = Router.ActiveRouteHandler;
3+
var { Route, RouteHandler, Link } = Router;
84

9-
var AsyncReactComponent = {
5+
var AsyncElement = {
106
loadedComponent: null,
117

128
load: function () {
13-
if (this.constructor.loadedComponent) {
9+
if (this.constructor.loadedComponent)
1410
return;
15-
}
1611

1712
this.bundle(function (component) {
1813
this.constructor.loadedComponent = component;
@@ -27,25 +22,25 @@ var AsyncReactComponent = {
2722
render: function () {
2823
var component = this.constructor.loadedComponent;
2924
if (component) {
30-
// can't find ActiveRouteHandler in the loaded component, so we just grab
25+
// can't find RouteHandler in the loaded component, so we just grab
3126
// it here first.
32-
this.props.activeRoute = <ActiveRouteHandler />;
27+
this.props.activeRoute = <RouteHandler/>;
3328
return component(this.props);
3429
}
3530
return this.preRender();
3631
}
3732
};
3833

3934
var PreDashboard = React.createClass({
40-
mixins: [AsyncReactComponent],
35+
mixins: [ AsyncElement ],
4136
bundle: require('bundle?lazy!./dashboard.js'),
4237
preRender: function () {
4338
return <div>Loading dashboard...</div>
4439
}
4540
});
4641

4742
var PreInbox = React.createClass({
48-
mixins: [AsyncReactComponent],
43+
mixins: [ AsyncElement ],
4944
bundle: require('bundle?lazy!./inbox.js'),
5045
preRender: function () {
5146
return <div>Loading inbox...</div>
@@ -60,7 +55,7 @@ var App = React.createClass({
6055
<ul>
6156
<li><Link to="dashboard">Dashboard</Link></li>
6257
</ul>
63-
<ActiveRouteHandler/>
58+
<RouteHandler/>
6459
</div>
6560
);
6661
}
@@ -75,6 +70,5 @@ var routes = (
7570
);
7671

7772
Router.run(routes, function (Handler) {
78-
React.renderComponent(<Handler/>, document.getElementById('example'));
73+
React.render(<Handler/>, document.getElementById('example'));
7974
});
80-

examples/partial-app-loading/dashboard.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/** @jsx React.DOM */
2-
31
var React = require('react');
42
var Router = require('react-router');
5-
var Link = Router.Link;
3+
var { RouteHandler, Link } = Router;
64

75
var Dashboard = React.createClass({
86

@@ -13,7 +11,7 @@ var Dashboard = React.createClass({
1311
<ul>
1412
<li><Link to="inbox">Inbox</Link></li>
1513
</ul>
16-
{this.props.activeRoute}
14+
<RouteHandler/>
1715
</div>
1816
);
1917
}

examples/partial-app-loading/inbox.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx React.DOM */
2-
31
var React = require('react');
42

53
var Inbox = React.createClass({

0 commit comments

Comments
 (0)