简体   繁体   English

未捕获的TypeError:无法读取react-redux中未定义的属性'props'

[英]Uncaught TypeError: Cannot read property 'props' of undefined in react-redux

i got the error Uncaught TypeError: Cannot read property 'props' of undefined when i tried to change the props of state in react-redux, here's my code to change: 我收到错误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]
    })
  }

Do the following: 请执行下列操作:

handleChange = (newDateRange) => {
    this.props.fetchMatches({
      ...this.props,
      startDate: newDateRange[0],
      endDate: newDateRange[1]
    })
  }

or in constructor, do 或在构造函数中

constructor(){
    super(props);
    this.handleChange = this.handleChange.bind(this);
}

In handleChange , it is not able to find the context , due to which this is undefined. handleChange ,它是不是能够找到context ,由于它this是不确定的。 Either you'll have to explicitly bind this or use arrow function 您将必须明确绑定this或使用箭头功能

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Redux - Uncaught(in promise)TypeError:无法读取未定义的属性'props' - React Redux - Uncaught (in promise) TypeError: Cannot read property 'props' of undefined 为什么会出现“ TypeError:无法读取未定义的属性” props”(反应路由器,React-Redux)? - Why am I getting 'TypeError: Cannot read property 'props' of undefined' (react-router, React-Redux)? React-Redux TypeError:无法读取未定义的属性“ setStatus” - React-Redux TypeError: Cannot read property 'setStatus' of undefined TypeError:无法读取react-redux中未定义的属性“map” - TypeError: Cannot read property 'map' of undefined in react-redux 类型错误:无法使用 react-redux 读取未定义的属性“地图” - TypeError: Cannot read property 'map' of undefined with react-redux 类型错误:无法读取未定义 React-Redux 的属性“地图” - TypeError: Cannot read property 'map' of undefined React-Redux 错误:类型错误:无法读取 React-Redux 中未定义的属性“map” - Error: TypeError: Cannot read property 'map' of undefined in React-Redux TypeError:无法读取未定义的属性“操作”(React-Redux) - TypeError: Cannot read property 'actions' of undefined (React-Redux) React-redux:无法使用connect获取作为道具的商店,无法读取未定义错误的属性“ props” - React-redux: cannot fetch the store as props using connect, Cannot read property 'props' of undefined error React/Redux - TypeError:无法读取未定义的属性“道具” - React/Redux - TypeError: Cannot read property 'props' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM