Skip to content

Commit 125a6db

Browse files
committed
add react-router
1 parent 4f7bd84 commit 125a6db

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

app/app.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import 'normalize.css/normalize.css';
55
import './scss/app.scss';
66

77
import React from 'react';
8-
import App from './components/App/App';
8+
import Router from 'react-router';
99

10-
React.render(
11-
<App />,
12-
document.getElementById('app')
13-
);
10+
import routes from './routes';
11+
12+
Router.run(routes, function (Handler) {
13+
React.render(React.createElement(Handler), document.body);
14+
});

app/components/App/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import styles from './_App.scss';
22

33
import React from 'react';
4+
import { RouteHandler } from 'react-router';
45
import AppActions from '../../actions/AppActions';
56
import ItemsStore from '../../stores/ItemsStore';
6-
import Body from '../Body/Body';
77
import Footer from '../Footer/Footer';
88

99
export default class App extends React.Component {
@@ -19,7 +19,7 @@ export default class App extends React.Component {
1919
render() {
2020
return (
2121
<div className={styles.app}>
22-
<Body items={this.state.items} />
22+
<RouteHandler items={this.state.items} />
2323
<Footer />
2424
</div>
2525
);

app/components/Body/Body.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styles from './_Body.scss';
2+
23
import React from 'react';
34
import Menu from '../Menu/Menu';
45

@@ -18,7 +19,7 @@ export default class Body extends React.Component {
1819
return (
1920
<div className={styles.body}>
2021
<h1 className={styles.header}>React Seed</h1>
21-
<p>This is an example seed app, powered by React, ES6 &amp; webpack.</p>
22+
<p>This is an example seed app, powered by React, ES6, Al &amp; webpack.</p>
2223
<p>Here is some example data:</p>
2324
<Menu items={this.props.items} />
2425
<h2>Getting started</h2>

app/routes.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import { Route, DefaultRoute } from 'react-router';
3+
import App from './components/App/App';
4+
import Body from './components/Body/Body';
5+
6+
export default (
7+
<Route path="/" handler={App}>
8+
<DefaultRoute name="home" handler={Body}/>
9+
</Route>
10+
);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"classnames": "^2.1.3",
3030
"flux": "^2.0.3",
3131
"normalize.css": "^3.0.3",
32-
"react": "^0.13.3"
32+
"react": "^0.13.3",
33+
"react-router": "^0.13.3"
3334
},
3435
"devDependencies": {
3536
"autoprefixer-core": "^5.2.1",

0 commit comments

Comments
 (0)