浏览代码

Lesson 06 Final

Ryan Florence 9 年之前
父节点
当前提交
04fc5fa4db
共有 3 个文件被更改,包括 24 次插入1 次删除
  1. 2 0
      index.js
  2. 12 0
      modules/Repo.js
  3. 10 1
      modules/Repos.js

+ 2 - 0
index.js

@@ -4,11 +4,13 @@ import { Router, Route, hashHistory } from 'react-router'
 import App from './modules/App'
 import About from './modules/About'
 import Repos from './modules/Repos'
+import Repo from './modules/Repo'
 
 render((
   <Router history={hashHistory}>
     <Route path="/" component={App}>
       <Route path="/repos" component={Repos}/>
+      <Route path="/repos/:userName/:repoName" component={Repo}/>
       <Route path="/about" component={About}/>
     </Route>
   </Router>

+ 12 - 0
modules/Repo.js

@@ -0,0 +1,12 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h2>{this.props.params.repoName}</h2>
+      </div>
+    )
+  }
+})
+

+ 10 - 1
modules/Repos.js

@@ -1,8 +1,17 @@
 import React from 'react'
+import { Link } from 'react-router'
 
 export default React.createClass({
   render() {
-    return <div>Repos</div>
+    return (
+      <div>
+        <h2>Repos</h2>
+        <ul>
+          <li><Link to="/repos/rackt/react-router">React Router</Link></li>
+          <li><Link to="/repos/facebook/react">React</Link></li>
+        </ul>
+      </div>
+    )
   }
 })