![](/img/trans.png)
[英]React Redux - Uncaught (in promise) TypeError: Cannot read property 'props' of undefined
[英]Uncaught TypeError: Cannot read property 'props' of undefined in react-redux
我收到錯誤Uncaught TypeError: Cannot read property 'props' of undefined
當我嘗試更改react-redux中的狀態道具時, Uncaught TypeError: Cannot read property 'props' of undefined
,這是我要更改的代碼:
class Home extends Component {
componentWillMount(){
this.props.fetchMatches();
}
handleChange(newDateRange){
this.props.fetchMatches({
...this.props,
startDate: newDateRange[0],
endDate: newDateRange[1]
})
}
請執行下列操作:
handleChange = (newDateRange) => {
this.props.fetchMatches({
...this.props,
startDate: newDateRange[0],
endDate: newDateRange[1]
})
}
或在構造函數中
constructor(){
super(props);
this.handleChange = this.handleChange.bind(this);
}
在handleChange
,它是不是能夠找到context
,由於它this
是不確定的。 您將必須明確綁定this
或使用箭頭功能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.