# 组件内部渲染组件

在组件内部也可以很容易渲染别的组件。只需要使用createChild函数就可以做到。

例如，让helloworld组件支持别的组件渲染：

```_raw_json
{
    "type": "helloworld",
    "controls": [{
        "type": "text",
        "text": "A"
    }, {
        "type": "text",
        "text": "B"
    }, {
        "type": "text",
        "text": "C"
    }]
}
```

调用createChild函数就能很轻易让helloworld组件渲染controls数组下面的所有组件。

```javascript
import {createChild} from 'rcre-core';

// ...
render() {
    let info = this.getPropsInfo(this.props.info);
    let child = info.controls.map((childInfo, key) => {
        return createChild(childInfo, {
            ...this.props,
            info: childInfo,
            key: key
        });
    });
    
    return (
        <div>child elements: {child}</div>
    );
}
```

createChild的第一个参数是子级组件的json配置。

第二个参数是子级组件的props值，第三个参数是子级组件的子级组件。

