-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
65 lines (50 loc) · 1.62 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var React = require('react');
var Router = require('react-router');
var { Route, DefaultRoute, NotFoundRoute, RouteHandler } = Router;
var TodoApp = require('./components/TodoApp.react');
var TodoConstants = require('./constants/TodoConstants');
/* */
function makeTodoAppWithFilter(filter) {
return React.createClass({
render: function() {
return <TodoApp filter={filter} />
}
});
}
// Some auto detection when in dev and on Github pages
var parentPath = '/random/react-flux-todo-list-demo-project/';
if(window.location.host === 'madlittlemods.github.io') {
parentPath = '/react-flux-todomvc/';
}
var routes = (
<Route handler={RouteHandler} path={parentPath} ignoreScrollBehavior>
<DefaultRoute handler={TodoApp} />
<NotFoundRoute handler={TodoApp} />
<Route name="all" handler={makeTodoAppWithFilter(TodoConstants.TODO_FILTER_ALL)} />
<Route name="active" handler={makeTodoAppWithFilter(TodoConstants.TODO_FILTER_ACTIVE)} />
<Route name="completed" handler={makeTodoAppWithFilter(TodoConstants.TODO_FILTER_COMPLETED)} />
</Route>
);
Router.create({
routes: routes,
location: Router.HistoryLocation
}).run(function (Handler, state) {
React.render(<Handler />, document.getElementById('todoapp'));
});
/* */
/* * /
var routes = (
<Route path="/random/react-flux-todo-list-demo-project/">
<DefaultRoute handler={TodoApp} />
</Route>
);
Router.run(routes, Router.HistoryLocation, function (Handler) {
React.render(<Handler />, document.getElementById('todoapp'));
});
/* */
/* * /
React.render(
<TodoApp />,
document.getElementById('todoapp')
);
/* */