Я использую React, Material-UI и lodash, но следующий код в методе рендеринга выдает ошибку «TypeError: Невозможно прочитать свойство« selectPage »из undefined»:
tmppage = _.map(_.range(0, this.state.groupsdt.length), function (i) {
return (
<MenuItem >
<IconButton onClick={() => { {this.selectPage(i)} }}><WebAsset /></IconButton>
Page {i + 1}
</MenuItem>
)
});
I 'мы определили this.selectPage в конструкторе (props) следующим образом:
constructor(props){
super(props);
this.state = {
loading: true,
modalopen: false,
menuopen: false,
urls:null,
groupsdt:null,
webkey:null,
currentpage:0,
currentBreakpoint: 'lg',
mounted: false,
layouts: {lg: null},
opentopublic:false,
};
this.addPage = this.addPage.bind(this);
this.selectPage = this.selectPage.bind(this);
this.addBox = this.addBox.bind(this);
this.removeBox = this.removeBox.bind(this);
this.doPost = this.doPost.bind(this);
this.doHome = this.doHome.bind(this);
}
Скажите, пожалуйста, что мне не хватает ... и заранее спасибо.