`:
```
var Example = React.createClass({
render: function() {
return (
Hello
World
);
}
});
```
虽然不能在render 方法中返回一个结点数组,但是可以在变量中使用数组,只需要给数组中的结点添加合适的key 属性即可:
```
var Example = React.createClass({
render: function() {
var greeting = [
Hello,
' ',
World,
'!'
];
return (
{greeting}
);
}
});
```
值得注意的是,你还可以在数组中混入空格与其他字符串,并且不需要给它们添加key属性。
在某种程度上,这类似于从父组件接收任意数量的参数,并通过render() 函数进行传播:
```
var Example = React.createClass({
render: function() {
console.log(this.props.children.length); // 4
return (
{this.props.children}
);
}
});
React.render(
Hello
{' '}
World
!
,
document.getElementById('app')
);
```