You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Play with the source files under the repo's demo* directories.
30
30
</html>
31
31
```
32
32
33
-
## Render JSX
33
+
## Demo1: Render JSX
34
34
35
35
React.render() translates JSX into HTML.
36
36
@@ -41,7 +41,7 @@ React.render(
41
41
);
42
42
```
43
43
44
-
## Use JavaScript in JSX
44
+
## Demo2: Use JavaScript in JSX
45
45
46
46
JSX takes angle brackets (beginning with < ) as HTML section, curly brackets (beginning with { ) as JavaScript section.
47
47
@@ -60,7 +60,7 @@ React.render(
60
60
);
61
61
```
62
62
63
-
## Use array in JSX
63
+
## Demo3: Use array in JSX
64
64
65
65
JSX implicitly concats all members of an array into HTML.
66
66
@@ -75,7 +75,7 @@ React.render(
75
75
);
76
76
```
77
77
78
-
## Define a component
78
+
## Demo4: Define a component
79
79
80
80
React.createClass() defines a component which you could use in your pages.
81
81
@@ -92,7 +92,7 @@ React.render(
92
92
);
93
93
```
94
94
95
-
## this.props.children
95
+
## Demo5: this.props.children
96
96
97
97
React uses `this.props.children` to access a component's children.
98
98
@@ -120,7 +120,7 @@ React.render(
120
120
);
121
121
```
122
122
123
-
## Finding a DOM node
123
+
## Demo6: Finding a DOM node
124
124
125
125
React uses React.findDOMNode() to find a DOM node.
126
126
@@ -145,7 +145,7 @@ React.render(
145
145
);
146
146
```
147
147
148
-
## this.state
148
+
## Demo7: this.state
149
149
150
150
React thinks of component as state machines, and uses `this.state` to hold component's state, `this.setState()` to update `this.state` and re-render the component.
151
151
@@ -173,9 +173,9 @@ React.render(
173
173
);
174
174
```
175
175
176
-
## Form
176
+
## Demo8: Form
177
177
178
-
The `value` property of Form components, such as <input>, <textarea>, and <option>, is unaffected by any user input. If you wanted to update the value in response to user input, you could use the onChange event.
178
+
The `value` property of Form components, such as <input$gt;, <textarea$gt;, and <option$gt;, is unaffected by any user input. If you wanted to update the value in response to user input, you could use the onChange event.
179
179
180
180
```js
181
181
var Input =React.createClass({
@@ -199,7 +199,7 @@ var Input = React.createClass({
199
199
React.render(<Input/>, document.body);
200
200
```
201
201
202
-
## Component Lifecycle
202
+
## Demo9: Component Lifecycle
203
203
204
204
Components have three main parts of their lifecycle: Mounting, Updating and Unmounting. React provides hooks into these lifecycle part. `will` methods are called right before something happens, and `did` methods which are called right after something happens.
205
205
@@ -239,7 +239,7 @@ React.render(
239
239
);
240
240
```
241
241
242
-
## Ajax
242
+
## Demo10: Ajax
243
243
244
244
Fetch data in componentDidMount. When the response arrives, store the data in state, triggering a render to update your UI.
245
245
@@ -284,13 +284,15 @@ React.render(
284
284
285
285
### Precompiling JSX
286
286
287
-
Install the command-line tools.
287
+
All above demos don't use JSX compilation forclarity. In production environment, ensure to precompile JSX files before putting them online.
288
+
289
+
First, install the command-line tools.
288
290
289
291
```bash
290
292
$ npm install -g react-tools
291
293
```
292
294
293
-
Precompile your JSX files(.jsx) into JavaScript(.js).
295
+
Then precompile your JSXfiles(.jsx) into JavaScript(.js).
294
296
295
297
```bash
296
298
$ jsx -x src/ build/
@@ -317,6 +319,9 @@ Put the compiled JS files into HTML.
317
319
318
320
- [React's official site](http://facebook.github.io/react)
319
321
- [React's official examples](https://github.com/facebook/react/tree/master/examples)
322
+
- [React JS Tutorial and Guide to the Gotchas](https://zapier.com/engineering/react-js-tutorial-guide-gotchas/), by Justin Deal
323
+
- [React Primer](https://github.com/BinaryMuse/react-primer), by Binary Muse
324
+
- [jQuery versus React.js thinking](http://blog.zigomir.com/react.js/jquery/2015/01/11/jquery-versus-react-thinking.html), by zigomir
0 commit comments