mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
integrated react-router
This commit is contained in:
parent
2b8f46cb8c
commit
4d7198fab9
16
js/app.js
16
js/app.js
@ -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';
|
||||||
|
|
||||||
|
import HelloApp from './components/hello_app';
|
||||||
|
import ArtworkList from './components/artwork_list';
|
||||||
|
|
||||||
|
var Route = Router.Route;
|
||||||
|
|
||||||
|
var routes = (
|
||||||
|
<Route handler={HelloApp}>
|
||||||
|
<Route path="artworks" handler={ArtworkList}/>
|
||||||
|
</Route>
|
||||||
|
);
|
||||||
|
|
||||||
|
Router.run(routes, Router.HashLocation, (HelloApp) => {
|
||||||
React.render(
|
React.render(
|
||||||
<HelloApp />,
|
<HelloApp />,
|
||||||
document.getElementById('main')
|
document.getElementById('main')
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
13
js/components/artwork_list.js
Normal file
13
js/components/artwork_list.js
Normal 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;
|
@ -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 (
|
||||||
|
<div>
|
||||||
<h1>ascribe all the things!</h1>
|
<h1>ascribe all the things!</h1>
|
||||||
|
<RouteHandler/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user