Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获类型错误:无法读取属性';道具';react redux中未定义的_Javascript_Reactjs_React Redux_Redux Thunk - Fatal编程技术网

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),但状态不变!我不知道你想说什么。这将解决您在问题中提出的问题。