Skip to content

Commit 36759fd

Browse files
committed
feat: add gh-pages
1 parent fb92e78 commit 36759fd

File tree

1 file changed

+53
-26
lines changed

1 file changed

+53
-26
lines changed

README.md

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ These demos are purposely written in a simple and clear style. You will find no
66

77
- [Flux Demo](https://github.com/ruanyf/extremely-simple-flux-demo)
88
- [Webpack Demos](https://github.com/ruanyf/webpack-demos)
9+
- [React Testing Demo](https://github.com/ruanyf/react-testing-demo)
910
- [A boilerplate for React-Babel-Webpack project](https://github.com/ruanyf/react-babel-webpack-boilerplate)
1011

1112
## How to use
@@ -41,23 +42,25 @@ Then play with the source files under the repo's demo* directories.
4142

4243
## Index
4344

44-
1. [Render JSX](#demo01-render-jsx-source)
45-
1. [Use JavaScript in JSX](#demo02-use-javascript-in-jsx-source)
46-
1. [Use array in JSX](#demo03-use-array-in-jsx-source)
47-
1. [Define a component](#demo04-define-a-component-source)
48-
1. [this.props.children](#demo05-thispropschildren-source)
49-
1. [PropTypes](#demo06-proptypes-source)
50-
1. [Finding a DOM node](#demo07-finding-a-dom-node-source)
51-
1. [this.state](#demo08-thisstate-source)
52-
1. [Form](#demo09-form-source)
53-
1. [Component Lifecycle](#demo10-component-lifecycle-source)
54-
1. [Ajax](#demo11-ajax-source)
55-
1. [Display value from a Promise](#demo12-display-value-from-a-promise-source)
56-
1. [Server-side rendering](#demo13-server-side-rendering-source)
45+
1. [Render JSX](#demo01-render-jsx)
46+
1. [Use JavaScript in JSX](#demo02-use-javascript-in-jsx)
47+
1. [Use array in JSX](#demo03-use-array-in-jsx)
48+
1. [Define a component](#demo04-define-a-component)
49+
1. [this.props.children](#demo05-thispropschildren)
50+
1. [PropTypes](#demo06-proptypes)
51+
1. [Finding a DOM node](#demo07-finding-a-dom-node)
52+
1. [this.state](#demo08-thisstate)
53+
1. [Form](#demo09-form)
54+
1. [Component Lifecycle](#demo10-component-lifecycle)
55+
1. [Ajax](#demo11-ajax)
56+
1. [Display value from a Promise](#demo12-display-value-from-a-promise)
57+
1. [Server-side rendering](#demo13-server-side-rendering)
5758

5859
---
5960

60-
## Demo01: Render JSX ([source](https://github.com/ruanyf/react-demos/blob/master/demo01/index.html))
61+
## Demo01: Render JSX
62+
63+
[demo](http://ruanyf.github.io/react-demos/demo01/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo01/index.html)
6164

6265
The template syntax in React is called [JSX](http://facebook.github.io/react/docs/displaying-data.html#jsx-syntax). It is allowed in JSX to put HTML tags directly into JavaScript codes. `ReactDOM.render()` is the method which translates JSX into HTML, and renders it into the specified DOM node.
6366

@@ -72,7 +75,9 @@ Attention, you have to use `<script type="text/babel">` to indicate JSX codes, a
7275

7376
Before v0.14, React use `JSTransform.js` to translate `<script type="text/jsx">`. It has been deprecated ([more info](https://facebook.github.io/react/blog/2015/06/12/deprecating-jstransform-and-react-tools.html)).
7477

75-
## Demo02: Use JavaScript in JSX ([source](https://github.com/ruanyf/react-demos/blob/master/demo02/index.html))
78+
## Demo02: Use JavaScript in JSX
79+
80+
[demo](http://ruanyf.github.io/react-demos/demo02/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo02/index.html)
7681

7782
You could also use JavaScript in JSX. It takes angle brackets (&lt;) as the beginning of HTML syntax, and curly brackets ({) as the beginning of JavaScript syntax.
7883

@@ -91,7 +96,9 @@ ReactDOM.render(
9196
);
9297
```
9398

94-
## Demo03: Use array in JSX ([source](https://github.com/ruanyf/react-demos/blob/master/demo03/index.html))
99+
## Demo03: Use array in JSX
100+
101+
[demo](http://ruanyf.github.io/react-demos/demo03/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo03/index.html)
95102

96103
If a JavaScript variable is array, JSX will implicitly concat all members of the array.
97104

@@ -106,7 +113,9 @@ ReactDOM.render(
106113
);
107114
```
108115

109-
## Demo04: Define a component ([source](https://github.com/ruanyf/react-demos/blob/master/demo04/index.html))
116+
## Demo04: Define a component
117+
118+
[demo](http://ruanyf.github.io/react-demos/demo04/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo04/index.html)
110119

111120
`React.createClass()` creates a component class, which implements a render method to return an component instance of the class. You don't need to call `new` on the class in order to get an instance, just use it as a normal HTML tag.
112121

@@ -150,7 +159,9 @@ var HelloMessage = React.createClass({
150159
});
151160
```
152161

153-
## Demo05: this.props.children ([source](https://github.com/ruanyf/react-demos/blob/master/demo05/index.html))
162+
## Demo05: this.props.children
163+
164+
[demo](http://ruanyf.github.io/react-demos/demo05/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo05/index.html)
154165

155166
React uses `this.props.children` to access a component's children nodes.
156167

@@ -182,7 +193,9 @@ Please be minded that the value of `this.props.children` has three possibilities
182193

183194
React gave us an utility [`React.Children`](https://facebook.github.io/react/docs/top-level-api.html#react.children) for dealing with the `this.props.children`'s opaque data structure. You could use `React.Children.map` to iterate `this.props.children` without worring its data type being `undefined` or `object`. Check [official document](https://facebook.github.io/react/docs/top-level-api.html#react.children) for more methods `React.Children` offers.
184195

185-
## Demo06: PropTypes ([source](https://github.com/ruanyf/react-demos/blob/master/demo06/index.html))
196+
## Demo06: PropTypes
197+
198+
[demo](http://ruanyf.github.io/react-demos/demo06/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo06/index.html)
186199

187200
Components have many specific attributes which are called ”props” in React and can be of any type.
188201

@@ -244,7 +257,9 @@ ReactDOM.render(
244257
);
245258
```
246259

247-
## Demo07: Finding a DOM node ([source](https://github.com/ruanyf/react-demos/blob/master/demo07/index.html))
260+
## Demo07: Finding a DOM node
261+
262+
[demo](http://ruanyf.github.io/react-demos/demo07/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo07/index.html)
248263

249264
Sometimes you need to reference a DOM node in a component. React gives you the `ref` attribute to find it.
250265

@@ -271,7 +286,9 @@ ReactDOM.render(
271286

272287
The desired DOM node should have a `ref` attribute, and `this.refs.[refName]` would return the corresponding DOM node. Please be minded that you could do that only after this component has been mounted into the DOM, otherwise you get `null`.
273288

274-
## Demo08: this.state ([source](https://github.com/ruanyf/react-demos/blob/master/demo08/index.html))
289+
## Demo08: this.state
290+
291+
[demo](http://ruanyf.github.io/react-demos/demo08/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo08/index.html)
275292

276293
React thinks of component as state machines, and uses `this.state` to hold component's state, `getInitialState()` to initialize `this.state`(invoked before a component is mounted), `this.setState()` to update `this.state` and re-render the component.
277294

@@ -301,7 +318,9 @@ ReactDOM.render(
301318

302319
You could use component attributes to register event handlers, just like `onClick`, `onKeyDown`, `onCopy`, etc. Official Document has all [supported events](http://facebook.github.io/react/docs/events.html#supported-events).
303320

304-
## Demo09: Form ([source](https://github.com/ruanyf/react-demos/blob/master/demo09/index.html))
321+
## Demo09: Form
322+
323+
[demo](http://ruanyf.github.io/react-demos/demo09/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo09/index.html)
305324

306325
According to React's design philosophy, `this.state` describes the state of component and is mutated via user interactions, and `this.props` describes the properties of component and is stable and immutable.
307326

@@ -331,7 +350,9 @@ ReactDOM.render(<Input/>, document.body);
331350

332351
More information on [official document](http://facebook.github.io/react/docs/forms.html).
333352

334-
## Demo10: Component Lifecycle ([source](https://github.com/ruanyf/react-demos/blob/master/demo10/index.html))
353+
## Demo10: Component Lifecycle
354+
355+
[demo](http://ruanyf.github.io/react-demos/demo10/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo10/index.html)
335356

336357
Components have three main parts of [their lifecycle](https://facebook.github.io/react/docs/working-with-the-browser.html#component-lifecycle): Mounting(being inserted into the DOM), Updating(being re-rendered) and Unmounting(being removed from the DOM). 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.
337358

@@ -381,7 +402,9 @@ The following is [a whole list of lifecycle methods](http://facebook.github.io/r
381402
- **componentWillReceiveProps(object nextProps)**: Fired when a component is receiving new props. You might want to `this.setState` depending on the props.
382403
- **shouldComponentUpdate(object nextProps, object nextState)**: Fired before rendering when new props or state are received. `return false` if you know an update isn't needed.
383404

384-
## Demo11: Ajax ([source](https://github.com/ruanyf/react-demos/blob/master/demo11/index.html))
405+
## Demo11: Ajax
406+
407+
[demo](http://ruanyf.github.io/react-demos/demo11/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo11/index.html)
385408

386409
How to get the data of a component from a server or an API provider? The answer is using Ajax to fetch data in the event handler of `componentDidMount`. When the server response arrives, store the data with `this.setState()` to trigger a re-render of your UI.
387410

@@ -422,7 +445,9 @@ ReactDOM.render(
422445
);
423446
```
424447
425-
## Demo12: Display value from a Promise ([source](https://github.com/ruanyf/react-demos/tree/master/demo12/index.html))
448+
## Demo12: Display value from a Promise
449+
450+
[demo](http://ruanyf.github.io/react-demos/demo12/) / [source](https://github.com/ruanyf/react-demos/blob/master/demo12/index.html)
426451
427452
This demo is inspired by Nat Pryce's article ["Higher Order React Components"](http://natpryce.com/articles/000814.html).
428453

@@ -480,7 +505,9 @@ var RepoList = React.createClass({
480505
});
481506
```
482507
483-
## Demo13: Server-side rendering ([source](https://github.com/ruanyf/react-demos/tree/master/demo13/src))
508+
## Demo13: Server-side rendering
509+
510+
[source](https://github.com/ruanyf/react-demos/tree/master/demo13/src)
484511
485512
This demo is copied from [github.com/mhart/react-server-example](https://github.com/mhart/react-server-example), but I rewrote it with JSX syntax.
486513

0 commit comments

Comments
 (0)