Make sure you use arrow functions to correctly bind 'this'
handlePageChange = (page) => {
this.setState({ currentPage: page });
}
This will give you 'this.setstate is not a function'
handlePageChange(page){
this.setState({ currentPage: page });
}
constructor(props) {
super(props)
this.onClick = this.onClick.bind(this)
}
onClick () {
this.setState({...})
}
Make sure you use arrow functions to correctly bind 'this'
handlePageChange = (page) => {
this.setState({ currentPage: page });
}
This will give you 'this.setstate is not a function'
handlePageChange(page){
this.setState({ currentPage: page });
}
VK.api('users.get',{fields: 'photo_50'},function(data){
if(data.response){
this.setState({ //the error happens here
FirstName: data.response[0].first_name
});
console.info(this.state.FirstName);
}
}.bind(this));