0
ChartProvider正根据配置文件生成图表列表。我正在尝试渲染MainComponent中的所有图表。获取错误 - 对象作为React子项无效
我得到错误:“对象作为React子元素无效(找到:带有键{}的对象)如果您打算渲染一组子对象,请改为使用数组,或者使用createFragment对象)来自React附加组件。“
MainComponent:
var React = require('React');
var Chart = require('ChartProvider');
var MainComponent = React.createClass({
render: function() {
return (
<div>
{Chart}
</div>
);
}
});
ChartProvider.js
var item = config.wList.map(function(widget, index) {
return (
<ChartComponent width="500px" height="400px"
options={{title: widget.title}} />
);
});
module.exports = item ;
Config.js文件中包含的数据:
module.exports = {
wList : [ {
title : "Average(Kbps)",
}, {
title : "Average DL(Kbps)",
}, {
title : "DL",
},
{
title : "Minutes",
}, {
title : "Cell",
}, {
title : "UL",
}]
};
继承人的作品笔,看看你能不能用叉子瑞普你的问题。 http://codepen.io/anon/pen/rWxyyv?editors=1010 – skav
@skav谢谢。现在没有错误。 – user2194838