Javascript 未捕获类型错误:无法读取属性';道具';react redux中未定义的
我遇到错误Javascript 未捕获类型错误:无法读取属性';道具';react redux中未定义的,javascript,reactjs,react-redux,redux-thunk,Javascript,Reactjs,React Redux,Redux Thunk,我遇到错误Uncaught TypeError:无法读取未定义的属性“props”当我试图在react redux中更改状态的props时,下面是我要更改的代码: class Home extends Component { componentWillMount(){ this.props.fetchMatches(); } handleChange(newDateRange){ this.props.fetchMatches({ ...this.pro
Uncaught TypeError:无法读取未定义的属性“props”
当我试图在react redux中更改状态的props时,下面是我要更改的代码:
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
中,无法找到上下文
,因此此
未定义。您必须显式绑定此
或使用您可以在此处找到答案@穆罕默德认为你发送的答案这个.props
未定义。在这种情况下,此
未定义。请尝试在构造函数中绑定“this”。this.handleChange=this.handleChange.bind(this),但状态不变!我不知道你想说什么。这将解决您在问题中提出的问题。