我刚接触Reactjs,并正在使用Cordova和Reactjs制作目录浏览应用程序。
目前,我遇到了错误this.props.onClick不是一个函数
,我发现this.props.onClick
未定义。请查看我的代码如下:
var RepositoryList = React.createClass({
//updating the list from a child folder entry
updateListFromChild:function(childFolder){
console.log("in parent update");
},
render:function(){
console.log(this.updateListFromChild); //function()
var itemsInRepo = this.props.items.map(function(entry){
console.log("in map: " + this.updateListFromChild); //undefined
return (
<RepositoryEntry repositoryItem={entry}
folderOnClick={this.updateListFromChild} />
);
});
return (
<ul className="table-view">
{itemsInRepo}
</ul>
);
}
});
folderOnClick
属性未定义。但我不知道如何解决这个问题。有人能指出吗?