Javascript 固定和#x27;js:1警告:不建议在严格模式下使用不安全的组件WillReceiveProps,这可能表明代码中存在错误;反应
我有一个更高阶的组件,它接收一个ex志愿者的comp和一个action,然后呈现一个包含志愿者信息的表: 志愿者薪酬代码:Javascript 固定和#x27;js:1警告:不建议在严格模式下使用不安全的组件WillReceiveProps,这可能表明代码中存在错误;反应,javascript,reactjs,react-redux,Javascript,Reactjs,React Redux,我有一个更高阶的组件,它接收一个ex志愿者的comp和一个action,然后呈现一个包含志愿者信息的表: 志愿者薪酬代码: class Volenteer extends Component { render() { const title = 'רשימת מתנדבים'; const mode = 'work'; return ( <EntityTable columns
class Volenteer extends Component {
render() {
const title = 'רשימת מתנדבים';
const mode = 'work';
return (
<EntityTable
columns = {columns}
title = {title}
mode = {mode}
promiseProps = {this.props}
/>
)
}
}
export default WithEntity(Volenteer, requestVolunteerData() );
classevoleteer扩展组件{
render(){
const title=‘רשימתנים’;
常量模式=‘工作’;
返回(
)
}
}
导出带有实体的默认值(ovoleteer,requestAutonologData());
临时守则是:
import React, {Component} from 'react';
import { connect } from 'react-redux';
const WithEntity = (EntityComponent, action) => {
const mapStateToProps = state => {
return {
isPending: state.requestEntitiesReducer.isPending,
entities: state.requestEntitiesReducer.entities,
error: state.requestEntitiesReducer.error
}
}
const mapDispatchToProps = dispatch => {
return {
onRequestEntities: () => dispatch(action)
}
}
class WithEntity extends Component {
componentDidMount () {
this.props.onRequestEntities();
}
render() {
return (
<EntityComponent {...this.props} />
)
}
}
return connect(mapStateToProps, mapDispatchToProps)(WithEntity);
}
export default WithEntity;
import React,{Component}来自'React';
从'react redux'导入{connect};
const with entity=(EntityComponent,action)=>{
常量mapStateToProps=状态=>{
返回{
isPending:state.requestEntitiesReducer.isPending,
实体:state.requestEntitiesReducer.entities,
错误:state.requestEntitiesReducer.error
}
}
const mapDispatchToProps=调度=>{
返回{
onRequestEntities:()=>分派(操作)
}
}
类WithEntity扩展组件{
组件安装(){
this.props.onRequestEntities();
}
render(){
返回(
)
}
}
返回连接(mapStateToProps、mapDispatchToProps)(WithEntity);
}
与实体导出默认值;
它工作正常,但我收到以下警告:
关于这一点也有类似的问题,但没有找到解决方案,而且我已经绑定到实现componentDidUpdate,但它失败了。使用componentDidMount生命周期是否存在问题
编辑:
消息中提到的DataProvider、FilterProvider或SortProvider组件来自react-bootstrap-table-2组件:
const Table = ( {data, columns, mode} ) => {
<div className = 'table-responsive fixed word-wrap scroll mapping_table'>
<BootstrapTable
bootstrap4
keyField={'id'}
data={data}
columns={columns}
responsive = {true}
condensed
hover
pagination={ paginationFactory()}
filter={ filterFactory() }
defaultSortDirection="asc"
/>
</div>
}
export default Table;
const Table=({data,columns,mode})=>{
}
导出默认表;
以下是组件列表的图片:
这是
react-bootstrap-table-2
组件中的一个已知问题,与您粘贴的HOC代码无关: