From 4d7198fab98b8ec740e7039bf17be663a2f163d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Fri, 15 May 2015 15:38:25 +0200 Subject: [PATCH] integrated react-router --- js/app.js | 20 ++++++++++++++++---- js/components/artwork_list.js | 13 +++++++++++++ js/components/hello_app.js | 8 +++++++- package.json | 3 ++- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 js/components/artwork_list.js diff --git a/js/app.js b/js/app.js index a5b9f236..293327d7 100644 --- a/js/app.js +++ b/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( - , - document.getElementById('main') +import HelloApp from './components/hello_app'; +import ArtworkList from './components/artwork_list'; + +var Route = Router.Route; + +var routes = ( + + + ); +Router.run(routes, Router.HashLocation, (HelloApp) => { + React.render( + , + document.getElementById('main') + ); +}); diff --git a/js/components/artwork_list.js b/js/components/artwork_list.js new file mode 100644 index 00000000..cc9a6666 --- /dev/null +++ b/js/components/artwork_list.js @@ -0,0 +1,13 @@ +import React from 'react'; + +class ArtworkList extends React.Component { + render () { + return ( +
    +
  • This is an artwork
  • +
+ ); + } +}; + +export default ArtworkList; diff --git a/js/components/hello_app.js b/js/components/hello_app.js index c01ae522..330fa9a2 100644 --- a/js/components/hello_app.js +++ b/js/components/hello_app.js @@ -1,9 +1,15 @@ import React from 'react'; +import Router from 'react-router'; + +var RouteHandler = Router.RouteHandler; class HelloApp extends React.Component { render () { return ( -

ascribe all the things!

+
+

ascribe all the things!

+ +
); } }; diff --git a/package.json b/package.json index ec1ad915..5a1098e2 100644 --- a/package.json +++ b/package.json @@ -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",