Initial commit from boilerplate
This commit is contained in:
32
src/App.js
Normal file
32
src/App.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import Router, { RouteHandler } from 'react-router';
|
||||
|
||||
class App extends React.Component {
|
||||
constructor( props, context ) {
|
||||
super();
|
||||
this.publishRouter( context.router );
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<RouteHandler />
|
||||
);
|
||||
}
|
||||
publishRouter( router ){
|
||||
var routes = {};
|
||||
|
||||
// Use route names as constants
|
||||
router.routes[0].childRoutes.forEach( function( r ){
|
||||
routes[ r.name ] = r.path;
|
||||
});
|
||||
|
||||
// Render the router accessible without contexts
|
||||
Router.currentRouter = router;
|
||||
Router.routes = routes;
|
||||
}
|
||||
}
|
||||
|
||||
App.contextTypes = {
|
||||
router: React.PropTypes.func
|
||||
};
|
||||
|
||||
export default App;
|
10
src/index.js
Normal file
10
src/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import Router from 'react-router';
|
||||
import routes from './routes';
|
||||
|
||||
Router.run( routes, Router.HistoryLocation, function( Handler ){
|
||||
React.render(
|
||||
React.createElement( Handler ),
|
||||
document.getElementById('root')
|
||||
);
|
||||
});
|
13
src/routes.js
Normal file
13
src/routes.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
import React from 'react';
|
||||
import Router, {Route, NotFoundRoute, DefaultRoute} from 'react-router';
|
||||
import App from './App';
|
||||
import Home from './ui/Home';
|
||||
|
||||
var routes = (
|
||||
<Route name="app" path="/" handler={ App } >
|
||||
<DefaultRoute name="home" handler={ Home } />
|
||||
</Route>
|
||||
);
|
||||
|
||||
export default routes;
|
12
src/ui/Home.js
Normal file
12
src/ui/Home.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
import React from 'react';
|
||||
|
||||
export default class Home extends React.Component {
|
||||
render(){
|
||||
return (
|
||||
<div>
|
||||
Hello world!
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user