mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
integrated react-router
This commit is contained in:
parent
2b8f46cb8c
commit
4d7198fab9
20
js/app.js
20
js/app.js
@ -1,10 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
import HelloApp from './components/hello_app';
|
||||
import Router from 'react-router';
|
||||
|
||||
React.render(
|
||||
<HelloApp />,
|
||||
document.getElementById('main')
|
||||
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(
|
||||
<HelloApp />,
|
||||
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 Router from 'react-router';
|
||||
|
||||
var RouteHandler = Router.RouteHandler;
|
||||
|
||||
class HelloApp extends React.Component {
|
||||
render () {
|
||||
return (
|
||||
<h1>ascribe all the things!</h1>
|
||||
<div>
|
||||
<h1>ascribe all the things!</h1>
|
||||
<RouteHandler/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,8 @@
|
||||
"alt": "^0.15.6",
|
||||
"classnames": "^1.2.2",
|
||||
"object-assign": "^2.0.0",
|
||||
"react": "^0.13.2"
|
||||
"react": "^0.13.2",
|
||||
"react-router": "^0.13.3"
|
||||
},
|
||||
"jest": {
|
||||
"scriptPreprocessor": "node_modules/babel-jest",
|
||||
|
Loading…
Reference in New Issue
Block a user