## 五、this.props.children
this.props 對象的屬性與組件的屬性一一對應,但是有一個例外,就是 this.props.children 屬性。它表示組件的所有子節點(查看?[demo05](https://github.com/ruanyf/react-demos/blob/master/demo05/index.html))。
> ~~~
> var NotesList = React.createClass({
> render: function() {
> return (
> <ol>
> {
> this.props.children.map(function (child) {
> return <li>{child}</li>
> })
> }
> </ol>
> );
> }
> });
>
> React.render(
> <NotesList>
> <span>hello</span>
> <span>world</span>
> </NotesList>,
> document.body
> );
> ~~~
上面代碼的 NoteList 組件有兩個 span 子節點,它們都可以通過 this.props.children 讀取,運行結果如下。

這里需要注意,只有當子節點多余1個時,this.props.children 才是一個數組,否則是不能用 map 方法的, 會報錯。