Javascript react native和redux中的hoc组件?
我想在用户请求Javascript react native和redux中的hoc组件?,javascript,reactjs,native,Javascript,Reactjs,Native,我想在用户请求Api调用时显示微调器 我把每一个组件传递到更高的顺序 要检查的组件是否正在请求 如果请求,则显示微调器,否则不显示 但这里我得到了一个错误,它说不能将类作为函数调用 //-------------Hoc Component HOC=component=>class extends React.component{ render(){ (return <component {...props} {...state}/>)} } } expor
Api
调用时显示微调器
我把每一个组件传递到更高的顺序
要检查的组件是否正在请求
如果请求,则显示微调器,否则不显示
但这里我得到了一个错误,它说不能将类作为函数调用
//-------------Hoc Component
HOC=component=>class extends React.component{
render(){
(return <component {...props} {...state}/>)}
}
}
export default connect(mapStateToProps)(HOC)
//----------login component
export default HOC(connect(mapStateToProps,{actions})(Login))
/--------------Hoc组件
HOC=component=>类扩展了React.component{
render(){
(返回)}
}
}
导出默认连接(MapStateTops)(HOC)
//----------登录组件
导出默认HOC(连接(mapStateToProps,{actions})(登录))
如果没有HOC,它可以正常工作,但会出现HOC错误。请告诉我如何连接两个高阶组件的解决方案试试这段代码
const HOC = WrappedComponent => {
class abc extends Component {
render () {
return (
<WrappedComponent {...this.props} {...this.state} />
);
}
}
const mapStateToProps = state => ({ state });
const mapDispatchToProps = dispatch => bindActionCreaters({..actions}, dispatch);
return connect(mapStateToProps, mapDispatchToProps)(abc);
}
export default compose(
HOC,
connect(mapStateToProps)
)(Login);
const HOC=WrappedComponent=>{
类abc扩展组件{
渲染(){
返回(
);
}
}
常量mapStateToProps=state=>({state});
const-mapDispatchToProps=dispatch=>bindActionCreaters({..actions},dispatch);
返回连接(mapStateToProps、mapDispatchToProps)(abc);
}
导出默认组合(
HOC,
连接(MapStateTops)
)(登入);
您的问题不可读。请编辑以使其可读。保存前检查预览此-->HOC(连接(mapStateToProps,{actions})(登录))执行此操作-->connect(mapStateToProps,{actions}))(HOC((登录))不工作