【发布时间】:2020-07-23 21:10:16
【问题描述】:
const mapStateToProps = state => {
console.log(state);
return {
counter: state.counter,
isLogged: state.isLogged
}
}
这就是我通过州的方式。但是,错误提示计数器和 isLogged 未定义。为什么?
【问题讨论】:
-
您需要共享比这更多的代码。没有人可以仅通过查看函数来告诉您任何事情。你的减速机设置好了吗?他们有默认状态吗?您的数据是否流经您的 reducer?你的钩子里有数据吗?当您控制台日志状态时会发生什么?
标签: reactjs react-redux react-hooks react-state mapstatetoprops