integrated react-router

This commit is contained in:
Tim Daubenschütz 2015-05-15 15:38:25 +02:00
parent 2b8f46cb8c
commit 4d7198fab9
4 changed files with 38 additions and 6 deletions

View File

@ -1,10 +1,22 @@
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import HelloApp from './components/hello_app'; import Router from 'react-router';
React.render( import HelloApp from './components/hello_app';
<HelloApp />, import ArtworkList from './components/artwork_list';
document.getElementById('main')
var Route = Router.Route;
var routes = (
<Route handler={HelloApp}>
<Route path="artworks" handler={ArtworkList}/>
</Route>
); );
Router.run(routes, Router.HashLocation, (HelloApp) => {
React.render(
<HelloApp />,
document.getElementById('main')
);
});

View File

@ -0,0 +1,13 @@
import React from 'react';
class ArtworkList extends React.Component {
render () {
return (
<ul>
<li>This is an artwork</li>
</ul>
);
}
};
export default ArtworkList;

View File

@ -1,9 +1,15 @@
import React from 'react'; import React from 'react';
import Router from 'react-router';
var RouteHandler = Router.RouteHandler;
class HelloApp extends React.Component { class HelloApp extends React.Component {
render () { render () {
return ( return (
<h1>ascribe all the things!</h1> <div>
<h1>ascribe all the things!</h1>
<RouteHandler/>
</div>
); );
} }
}; };

View File

@ -29,7 +29,8 @@
"alt": "^0.15.6", "alt": "^0.15.6",
"classnames": "^1.2.2", "classnames": "^1.2.2",
"object-assign": "^2.0.0", "object-assign": "^2.0.0",
"react": "^0.13.2" "react": "^0.13.2",
"react-router": "^0.13.3"
}, },
"jest": { "jest": {
"scriptPreprocessor": "node_modules/babel-jest", "scriptPreprocessor": "node_modules/babel-jest",