reactjs - Redux mapStateToProps 到类反应组件
问题描述
我有这个代码
import {connect} from 'react-redux';
import { createStructuredSelector } from 'reselect';
class GroupsPage extends React.Component {
constructor(props){
super(props)
}
render(){
return();
}
};
const mapStateToProps = createStructuredSelector({
groups: selectGroups
})
export default connect(mapStateToProps)(GroupsPage);
我的问题是,如何将组对象从 mapStateToProps 获取到 GroupsPage 组件中?
解决方案
您的状态将在组件道具中,只需在构造函数中调用 console.log;
console.log(props.groups)
推荐阅读
- spring - Spring MVC + Thymeleaf:不加载一些资源
- python - 处理 Flask 中的嵌套目录
- reactjs - 如何在没有 mapDispatchToProps 的情况下键入 connect
- ios - List 渲染时加载屏幕 - SwiftUI
- python - python3 pip 存在时 python2 的 pip
- php - 检查对 Laravel 控制器的异步 API 调用的响应而不返回
- python - Networkx Edge_颜色变化无常
- c++ - 调试 CUDA MMU 故障
- angular - Ng If to false 创建空行 Mat Table Angular
- python - DRF @action decorator serializer.data 响应问题