Skip to content

Commit 2dc0d97

Browse files
committed
add react_learn02.md
1 parent c8d3cbf commit 2dc0d97

File tree

8 files changed

+295
-201
lines changed

8 files changed

+295
-201
lines changed

react-comment/README.md

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,13 @@
1-
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
21

3-
# React Tutorial
4-
5-
This is the React comment box example from [the React tutorial](http://facebook.github.io/react/docs/tutorial.html).
2+
# React Comment
63

74
## To use
85

9-
There are several simple server implementations included. They all serve static files from `public/` and handle requests to `/api/comments` to fetch or add data. Start a server with one of the following:
10-
11-
### Node
12-
136
```sh
147
npm install
158
node server.js
169
```
1710

18-
### Python
19-
20-
```sh
21-
pip install -r requirements.txt
22-
python server.py
23-
```
24-
25-
### Ruby
26-
```sh
27-
ruby server.rb
28-
```
29-
30-
### PHP
31-
```sh
32-
php server.php
33-
```
34-
35-
### Go
36-
```sh
37-
go run server.go
38-
```
39-
40-
### Perl
41-
42-
```sh
43-
cpan Mojolicious
44-
perl server.pl
45-
```
46-
4711
And visit <http://localhost:3000/>. Try opening multiple tabs!
4812

4913
## Changing the port

react-comment/comments.json

-10
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@
44
"title": "codingplayboy",
55
"text": "react vs angular"
66
},
7-
{
8-
"id": 1447843203580,
9-
"title": "zjw",
10-
"text": "eat sow"
11-
},
12-
{
13-
"id": 1471049564804,
14-
"title": "limuzi",
15-
"text": "hello,Sunday"
16-
},
177
{
188
"id": 1472134095308,
199
"title": "惊鸿",

react-comment/package.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "react-tutorial",
3-
"version": "0.0.0",
4-
"description": "Code from the React tutorial.",
2+
"name": "react-comment",
3+
"version": "0.0.1",
4+
"description": "React practice.",
55
"main": "server.js",
66
"dependencies": {
77
"body-parser": "^1.4.3",
@@ -18,16 +18,11 @@
1818
},
1919
"keywords": [
2020
"react",
21-
"tutorial",
2221
"comment",
2322
"example"
2423
],
25-
"author": "petehunt",
26-
"bugs": {
27-
"url": "https://github.com/reactjs/react-tutorial/issues"
28-
},
29-
"homepage": "https://github.com/reactjs/react-tutorial",
24+
"author": "惊鸿",
3025
"engines" : {
31-
"node" : "0.12.x"
26+
"node" : "6.8.x"
3227
}
3328
}

react-comment/public/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ <h1>Recent Posts</h1>
132132
</form>
133133
);
134134
}
135-
}); var Comment = React.createClass({
135+
});
136+
var Comment = React.createClass({
136137
rawMarkup: function(_data) {
137138
var rawMarkup = marked(_data,
138139
{

react-comment/public/scripts/example.js

-128
This file was deleted.

react-comment/server.js

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
/**
2-
* This file provided by Facebook is for non-commercial testing and evaluation
3-
* purposes only. Facebook reserves all rights not expressly granted.
4-
*
5-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8-
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9-
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11-
*/
12-
131
var fs = require('fs');
142
var path = require('path');
153
var express = require('express');

react_learn.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ React推荐创建组件处理特定需求,在应用中组合使用组件,实
109109

110110
### 单向数据流
111111

112-
React组件是一个状态机,每个组件内部都有自己的状态(state),其状态只在内部作用域下操作修改。多个组件之间可以是复合的关系,即父子组件关系,React组件提供设置组件属性(props),属性可以从父组件获取传递到各子组件
112+
React组件是一个状态机,每个组件内部都有自己的状态(state),其状态只在内部作用域下操作修改。多个组件之间可以是复合的关系,即从属组件关系,React组件提供设置组件属性(props),属性可以从主组件获取传递到各属组件
113113

114-
> 父组件与子组件通信,最简单的方式是通过props,父组件通过props传递回调函数给子组件,在回调函数里可以更新state,触发组件重绘;在子组件中调用回调函数,也可以传入数据参数。
114+
> 主组件与属组件通信,最简单的方式是通过props,主组件通过props传递回调函数给属组件,在回调函数里可以更新state,触发组件重绘;在属组件中调用回调函数,也可以传入数据参数。
115115
116116
#### props
117117

@@ -160,7 +160,7 @@ props即属性,我们可以给React组件设置属性,属性值可以是任
160160

161161
- setProps
162162

163-
我们也可以使用setProps()方法设置组件属性,但是只能在组建外或者子组件中调用该方法
163+
我们也可以使用setProps()方法设置组件属性,但是只能在组建外或者属组件中调用该方法
164164

165165
```
166166

0 commit comments

Comments
 (0)