Nat*_*rel 3 javascript reactjs react-redux
我有这个更高阶的组件,它接收前一个志愿者的补偿和一个操作,然后呈现一个包含志愿者信息的表格:\n志愿者补偿代码:
\nclass Volenteer extends Component {\n render() {\n const title = \'\xd7\xa8\xd7\xa9\xd7\x99\xd7\x9e\xd7\xaa \xd7\x9e\xd7\xaa\xd7\xa0\xd7\x93\xd7\x91\xd7\x99\xd7\x9d\';\n const mode = \'work\';\n return (\n <EntityTable \n columns = {columns}\n title = {title}\n mode = {mode}\n promiseProps = {this.props}\n />\n )\n }\n}\n\nexport default WithEntity(Volenteer, requestVolunteerData() );\nRun Code Online (Sandbox Code Playgroud)\nHOC代码是:
\nimport React, {Component} from \'react\';\nimport { connect } from \'react-redux\';\n\nconst WithEntity = (EntityComponent, action) => {\n\n const mapStateToProps = state => {\n return {\n isPending: state.requestEntitiesReducer.isPending,\n entities: state.requestEntitiesReducer.entities,\n error: state.requestEntitiesReducer.error\n }\n }\n \n const mapDispatchToProps = dispatch => {\n return {\n onRequestEntities: () => dispatch(action)\n }\n }\n\n class WithEntity extends Component {\n \n componentDidMount () {\n this.props.onRequestEntities();\n }\n\n \n\n render() {\n return (\n <EntityComponent {...this.props} />\n ) \n }\n }\n\n return connect(mapStateToProps, mapDispatchToProps)(WithEntity);\n}\n\nexport default WithEntity;\nRun Code Online (Sandbox Code Playgroud)\n\n关于此有类似的问题,但没有找到解决方案,我也绑定了实现 componentDidUpdate 但它失败了。使用 componentDidMount 生命周期有问题吗?
\n编辑: \n消息中提到的 DataProvider、FilterProvider 或 SortProvider 来自react-bootstrap-table-2 comp:
\nconst Table = ( {data, columns, mode} ) => {\n <div className = \'table-responsive fixed word-wrap scroll mapping_table\'>\n <BootstrapTable \n bootstrap4\n keyField={\'id\'}\n data={data}\n columns={columns} \n responsive = {true}\n condensed\n hover\n pagination={ paginationFactory()} \n filter={ filterFactory() }\n defaultSortDirection="asc"\n />\n </div>\n}\n \nexport default Table;\nRun Code Online (Sandbox Code Playgroud)\n\n