Cannot read property 'setState' of undefined
You're using function()
in your Promise chain, this will change the scope for this
. If you're using ES6 I suggest you use the arrow function to maintain the class scope. Example:
You're using
axios.get(APP_URL, { params: params}) .then(function(response) { // this resets the scope this.setState({ videos:response }) })
Try using arrow functions:
axios.get(APP_URL, { params: params})
.then((response) => {
this.setState({
videos:response
})
})
posted on 2017-11-21 14:51 camike_huihui 阅读(451) 评论(0) 编辑 收藏 举报