【发布时间】:2016-05-13 19:41:00
【问题描述】:
我正在尝试修改 react-router-redux 的示例代码。 https://github.com/rackt/react-router-redux/blob/master/examples/basic/components/Home.js
这是我的 Home.js
class Home extends Component {
onSubmit(props) {
this.props.routeActions.push('/foo');
}
}
我也有一个 mapDispatchToProps 。
function mapDispatchToProps(dispatch){
return bindActionCreators({ routeActions },dispatch);
}
当我调用 onSubmit 函数时,我得到一个错误
Uncaught TypeError: this.props.routeActions.push is not a function
如果我在 onSubmit 中删除 this.props,则 URL 中的键已更改,但仍位于同一页面上。
从localhost:8080/#/?_k=iwio19 到localhost:8080/#/?_k=ldn1ew
有人知道怎么解决吗? 欣赏它。
【问题讨论】:
-
请向我们展示您的完整 Home.js。
标签: reactjs react-router react-router-redux