瀏覽代碼

add code folder to contain all the code/exercises for each lessons

florida 9 年之前
父節點
當前提交
07a3113bfe
共有 100 個文件被更改,包括 1319 次插入0 次删除
  1. 7 0
      code/01-setting-up/index.html
  2. 4 0
      code/01-setting-up/index.js
  3. 8 0
      code/01-setting-up/modules/App.js
  4. 25 0
      code/01-setting-up/package.json
  5. 15 0
      code/01-setting-up/webpack.config.js
  6. 7 0
      code/02-rendering-a-router/index.html
  7. 4 0
      code/02-rendering-a-router/index.js
  8. 8 0
      code/02-rendering-a-router/modules/App.js
  9. 25 0
      code/02-rendering-a-router/package.json
  10. 15 0
      code/02-rendering-a-router/webpack.config.js
  11. 7 0
      code/03-navigating-with-link/index.html
  12. 15 0
      code/03-navigating-with-link/index.js
  13. 8 0
      code/03-navigating-with-link/modules/About.js
  14. 8 0
      code/03-navigating-with-link/modules/App.js
  15. 8 0
      code/03-navigating-with-link/modules/Repos.js
  16. 25 0
      code/03-navigating-with-link/package.json
  17. 15 0
      code/03-navigating-with-link/webpack.config.js
  18. 7 0
      code/04-nested-routes/index.html
  19. 15 0
      code/04-nested-routes/index.js
  20. 8 0
      code/04-nested-routes/modules/About.js
  21. 17 0
      code/04-nested-routes/modules/App.js
  22. 8 0
      code/04-nested-routes/modules/Repos.js
  23. 25 0
      code/04-nested-routes/package.json
  24. 15 0
      code/04-nested-routes/webpack.config.js
  25. 7 0
      code/05-active-links/index.html
  26. 16 0
      code/05-active-links/index.js
  27. 8 0
      code/05-active-links/modules/About.js
  28. 18 0
      code/05-active-links/modules/App.js
  29. 8 0
      code/05-active-links/modules/Repos.js
  30. 25 0
      code/05-active-links/package.json
  31. 15 0
      code/05-active-links/webpack.config.js
  32. 4 0
      code/06-params/index.css
  33. 8 0
      code/06-params/index.html
  34. 16 0
      code/06-params/index.js
  35. 8 0
      code/06-params/modules/About.js
  36. 18 0
      code/06-params/modules/App.js
  37. 10 0
      code/06-params/modules/NavLink.js
  38. 8 0
      code/06-params/modules/Repos.js
  39. 25 0
      code/06-params/package.json
  40. 15 0
      code/06-params/webpack.config.js
  41. 4 0
      code/07-more-nesting/index.css
  42. 8 0
      code/07-more-nesting/index.html
  43. 18 0
      code/07-more-nesting/index.js
  44. 8 0
      code/07-more-nesting/modules/About.js
  45. 18 0
      code/07-more-nesting/modules/App.js
  46. 10 0
      code/07-more-nesting/modules/NavLink.js
  47. 12 0
      code/07-more-nesting/modules/Repo.js
  48. 17 0
      code/07-more-nesting/modules/Repos.js
  49. 25 0
      code/07-more-nesting/package.json
  50. 15 0
      code/07-more-nesting/webpack.config.js
  51. 4 0
      code/08-index-routes/index.css
  52. 8 0
      code/08-index-routes/index.html
  53. 19 0
      code/08-index-routes/index.js
  54. 8 0
      code/08-index-routes/modules/About.js
  55. 18 0
      code/08-index-routes/modules/App.js
  56. 10 0
      code/08-index-routes/modules/NavLink.js
  57. 12 0
      code/08-index-routes/modules/Repo.js
  58. 18 0
      code/08-index-routes/modules/Repos.js
  59. 25 0
      code/08-index-routes/package.json
  60. 15 0
      code/08-index-routes/webpack.config.js
  61. 4 0
      code/09-index-links/index.css
  62. 8 0
      code/09-index-links/index.html
  63. 21 0
      code/09-index-links/index.js
  64. 8 0
      code/09-index-links/modules/About.js
  65. 18 0
      code/09-index-links/modules/App.js
  66. 8 0
      code/09-index-links/modules/Home.js
  67. 10 0
      code/09-index-links/modules/NavLink.js
  68. 12 0
      code/09-index-links/modules/Repo.js
  69. 18 0
      code/09-index-links/modules/Repos.js
  70. 25 0
      code/09-index-links/package.json
  71. 15 0
      code/09-index-links/webpack.config.js
  72. 4 0
      code/10-clean-urls/index.css
  73. 8 0
      code/10-clean-urls/index.html
  74. 21 0
      code/10-clean-urls/index.js
  75. 8 0
      code/10-clean-urls/modules/About.js
  76. 19 0
      code/10-clean-urls/modules/App.js
  77. 8 0
      code/10-clean-urls/modules/Home.js
  78. 10 0
      code/10-clean-urls/modules/NavLink.js
  79. 12 0
      code/10-clean-urls/modules/Repo.js
  80. 18 0
      code/10-clean-urls/modules/Repos.js
  81. 25 0
      code/10-clean-urls/package.json
  82. 15 0
      code/10-clean-urls/webpack.config.js
  83. 4 0
      code/11-productionish-server/index.css
  84. 8 0
      code/11-productionish-server/index.html
  85. 21 0
      code/11-productionish-server/index.js
  86. 8 0
      code/11-productionish-server/modules/About.js
  87. 19 0
      code/11-productionish-server/modules/App.js
  88. 8 0
      code/11-productionish-server/modules/Home.js
  89. 10 0
      code/11-productionish-server/modules/NavLink.js
  90. 12 0
      code/11-productionish-server/modules/Repo.js
  91. 18 0
      code/11-productionish-server/modules/Repos.js
  92. 25 0
      code/11-productionish-server/package.json
  93. 15 0
      code/11-productionish-server/webpack.config.js
  94. 21 0
      code/12-navigating/index.js
  95. 8 0
      code/12-navigating/modules/About.js
  96. 19 0
      code/12-navigating/modules/App.js
  97. 8 0
      code/12-navigating/modules/Home.js
  98. 10 0
      code/12-navigating/modules/NavLink.js
  99. 12 0
      code/12-navigating/modules/Repo.js
  100. 18 0
      code/12-navigating/modules/Repos.js

+ 7 - 0
code/01-setting-up/index.html

@@ -0,0 +1,7 @@
+<!doctype html public "storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 4 - 0
code/01-setting-up/index.js

@@ -0,0 +1,4 @@
+import React from 'react'
+import { render } from 'react-dom'
+import App from './modules/App'
+render(<App/>, document.getElementById('app'))

+ 8 - 0
code/01-setting-up/modules/App.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Hello, React Router!</div>
+  }
+})
+

+ 25 - 0
code/01-setting-up/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/01-setting-up/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 7 - 0
code/02-rendering-a-router/index.html

@@ -0,0 +1,7 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 4 - 0
code/02-rendering-a-router/index.js

@@ -0,0 +1,4 @@
+import React from 'react'
+import { render } from 'react-dom'
+import App from './modules/App'
+render(<App/>, document.getElementById('app'))

+ 8 - 0
code/02-rendering-a-router/modules/App.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Hello, React Router!</div>
+  }
+})
+

+ 25 - 0
code/02-rendering-a-router/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0-rc6"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/02-rendering-a-router/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 7 - 0
code/03-navigating-with-link/index.html

@@ -0,0 +1,7 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 15 - 0
code/03-navigating-with-link/index.js

@@ -0,0 +1,15 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}/>
+    <Route path="/repos" component={Repos}/>
+    <Route path="/about" component={About}/>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/03-navigating-with-link/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 8 - 0
code/03-navigating-with-link/modules/App.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Hello, React Router!</div>
+  }
+})
+

+ 8 - 0
code/03-navigating-with-link/modules/Repos.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Repos</div>
+  }
+})
+

+ 25 - 0
code/03-navigating-with-link/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/03-navigating-with-link/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 7 - 0
code/04-nested-routes/index.html

@@ -0,0 +1,7 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 15 - 0
code/04-nested-routes/index.js

@@ -0,0 +1,15 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}/>
+    <Route path="/repos" component={Repos}/>
+    <Route path="/about" component={About}/>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/04-nested-routes/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 17 - 0
code/04-nested-routes/modules/App.js

@@ -0,0 +1,17 @@
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><Link to="/about">About</Link></li>
+          <li><Link to="/repos">Repos</Link></li>
+        </ul>
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/04-nested-routes/modules/Repos.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Repos</div>
+  }
+})
+

+ 25 - 0
code/04-nested-routes/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/04-nested-routes/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 7 - 0
code/05-active-links/index.html

@@ -0,0 +1,7 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 16 - 0
code/05-active-links/index.js

@@ -0,0 +1,16 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}>
+      <Route path="/repos" component={Repos}/>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/05-active-links/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 18 - 0
code/05-active-links/modules/App.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><Link to="/about">About</Link></li>
+          <li><Link to="/repos">Repos</Link></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/05-active-links/modules/Repos.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Repos</div>
+  }
+})
+

+ 25 - 0
code/05-active-links/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/05-active-links/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/06-params/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/06-params/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=index.css>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 16 - 0
code/06-params/index.js

@@ -0,0 +1,16 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}>
+      <Route path="/repos" component={Repos}/>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/06-params/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 18 - 0
code/06-params/modules/App.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 10 - 0
code/06-params/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 8 - 0
code/06-params/modules/Repos.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Repos</div>
+  }
+})
+

+ 25 - 0
code/06-params/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/06-params/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/07-more-nesting/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/07-more-nesting/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=index.css>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 18 - 0
code/07-more-nesting/index.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import { render } from 'react-dom'
+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>
+), document.getElementById('app'))
+

+ 8 - 0
code/07-more-nesting/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 18 - 0
code/07-more-nesting/modules/App.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 10 - 0
code/07-more-nesting/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/07-more-nesting/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>
+    )
+  }
+})
+

+ 17 - 0
code/07-more-nesting/modules/Repos.js

@@ -0,0 +1,17 @@
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    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>
+    )
+  }
+})
+

+ 25 - 0
code/07-more-nesting/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/07-more-nesting/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/08-index-routes/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/08-index-routes/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=index.css>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 19 - 0
code/08-index-routes/index.js

@@ -0,0 +1,19 @@
+import React from 'react'
+import { render } from 'react-dom'
+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>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/08-index-routes/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 18 - 0
code/08-index-routes/modules/App.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 10 - 0
code/08-index-routes/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/08-index-routes/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>
+    )
+  }
+})
+

+ 18 - 0
code/08-index-routes/modules/Repos.js

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

+ 25 - 0
code/08-index-routes/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/08-index-routes/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/09-index-links/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/09-index-links/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=index.css>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 21 - 0
code/09-index-links/index.js

@@ -0,0 +1,21 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory, IndexRoute } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+import Repo from './modules/Repo'
+import Home from './modules/Home'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}>
+      <IndexRoute component={Home}/>
+      <Route path="/repos" component={Repos}>
+        <Route path="/repos/:userName/:repoName" component={Repo}/>
+      </Route>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/09-index-links/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 18 - 0
code/09-index-links/modules/App.js

@@ -0,0 +1,18 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/09-index-links/modules/Home.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Home</div>
+  }
+})
+

+ 10 - 0
code/09-index-links/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/09-index-links/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>
+    )
+  }
+})
+

+ 18 - 0
code/09-index-links/modules/Repos.js

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

+ 25 - 0
code/09-index-links/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/09-index-links/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/10-clean-urls/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/10-clean-urls/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=index.css>
+<div id=app></div>
+<script src="bundle.js"></script>
+

+ 21 - 0
code/10-clean-urls/index.js

@@ -0,0 +1,21 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, hashHistory, IndexRoute } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+import Repo from './modules/Repo'
+import Home from './modules/Home'
+
+render((
+  <Router history={hashHistory}>
+    <Route path="/" component={App}>
+      <IndexRoute component={Home}/>
+      <Route path="/repos" component={Repos}>
+        <Route path="/repos/:userName/:repoName" component={Repo}/>
+      </Route>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/10-clean-urls/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 19 - 0
code/10-clean-urls/modules/App.js

@@ -0,0 +1,19 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/" onlyActiveOnIndex>Home</NavLink></li>
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/10-clean-urls/modules/Home.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Home</div>
+  }
+})
+

+ 10 - 0
code/10-clean-urls/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/10-clean-urls/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>
+    )
+  }
+})
+

+ 18 - 0
code/10-clean-urls/modules/Repos.js

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

+ 25 - 0
code/10-clean-urls/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base ."
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/10-clean-urls/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: ''
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 4 - 0
code/11-productionish-server/index.css

@@ -0,0 +1,4 @@
+.active {
+  color: green;
+}
+

+ 8 - 0
code/11-productionish-server/index.html

@@ -0,0 +1,8 @@
+<!doctype html public="storage">
+<html>
+<meta charset=utf-8/>
+<title>My First React Router App</title>
+<link rel=stylesheet href=/index.css>
+<div id=app></div>
+<script src="/bundle.js"></script>
+

+ 21 - 0
code/11-productionish-server/index.js

@@ -0,0 +1,21 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, browserHistory, IndexRoute } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+import Repo from './modules/Repo'
+import Home from './modules/Home'
+
+render((
+  <Router history={browserHistory}>
+    <Route path="/" component={App}>
+      <IndexRoute component={Home}/>
+      <Route path="/repos" component={Repos}>
+        <Route path="/repos/:userName/:repoName" component={Repo}/>
+      </Route>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/11-productionish-server/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 19 - 0
code/11-productionish-server/modules/App.js

@@ -0,0 +1,19 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/" onlyActiveOnIndex>Home</NavLink></li>
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/11-productionish-server/modules/Home.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Home</div>
+  }
+})
+

+ 10 - 0
code/11-productionish-server/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/11-productionish-server/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>
+    )
+  }
+})
+

+ 18 - 0
code/11-productionish-server/modules/Repos.js

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

+ 25 - 0
code/11-productionish-server/package.json

@@ -0,0 +1,25 @@
+{
+  "name": "tutorial",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "start": "webpack-dev-server --inline --content-base . --history-api-fallback"
+  },
+  "author": "",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^0.14.7",
+    "react-dom": "^0.14.7",
+    "react-router": "^2.0.0"
+  },
+  "devDependencies": {
+    "babel-core": "^6.5.1",
+    "babel-loader": "^6.2.2",
+    "babel-preset-es2015": "^6.5.0",
+    "babel-preset-react": "^6.5.0",
+    "http-server": "^0.8.5",
+    "webpack": "^1.12.13",
+    "webpack-dev-server": "^1.14.1"
+  }
+}

+ 15 - 0
code/11-productionish-server/webpack.config.js

@@ -0,0 +1,15 @@
+module.exports = {
+  entry: './index.js',
+
+  output: {
+    filename: 'bundle.js',
+    publicPath: '/'
+  },
+
+  module: {
+    loaders: [
+      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
+    ]
+  }
+}
+

+ 21 - 0
code/12-navigating/index.js

@@ -0,0 +1,21 @@
+import React from 'react'
+import { render } from 'react-dom'
+import { Router, Route, browserHistory, IndexRoute } from 'react-router'
+import App from './modules/App'
+import About from './modules/About'
+import Repos from './modules/Repos'
+import Repo from './modules/Repo'
+import Home from './modules/Home'
+
+render((
+  <Router history={browserHistory}>
+    <Route path="/" component={App}>
+      <IndexRoute component={Home}/>
+      <Route path="/repos" component={Repos}>
+        <Route path="/repos/:userName/:repoName" component={Repo}/>
+      </Route>
+      <Route path="/about" component={About}/>
+    </Route>
+  </Router>
+), document.getElementById('app'))
+

+ 8 - 0
code/12-navigating/modules/About.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>About</div>
+  }
+})
+

+ 19 - 0
code/12-navigating/modules/App.js

@@ -0,0 +1,19 @@
+import React from 'react'
+import NavLink from './NavLink'
+
+export default React.createClass({
+  render() {
+    return (
+      <div>
+        <h1>React Router Tutorial</h1>
+        <ul role="nav">
+          <li><NavLink to="/" onlyActiveOnIndex>Home</NavLink></li>
+          <li><NavLink to="/about">About</NavLink></li>
+          <li><NavLink to="/repos">Repos</NavLink></li>
+        </ul>
+        {this.props.children}
+      </div>
+    )
+  }
+})
+

+ 8 - 0
code/12-navigating/modules/Home.js

@@ -0,0 +1,8 @@
+import React from 'react'
+
+export default React.createClass({
+  render() {
+    return <div>Home</div>
+  }
+})
+

+ 10 - 0
code/12-navigating/modules/NavLink.js

@@ -0,0 +1,10 @@
+// modules/NavLink.js
+import React from 'react'
+import { Link } from 'react-router'
+
+export default React.createClass({
+  render() {
+    return <Link {...this.props} activeClassName="active"/>
+  }
+})
+

+ 12 - 0
code/12-navigating/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>
+    )
+  }
+})
+

+ 18 - 0
code/12-navigating/modules/Repos.js

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

部分文件因文件數量過多而無法顯示