如下,是antd的drawer中的源码,代码中的DrawerContext的Consumer居然包裹住Provider,不都是Provider包裹Consumer的吗,该如何理解?//renderProviderforMulti-leveldrawerenderProvider=(value:Drawer)=>{let{zIndex,style,placement,className,wrapClassName,width,height,...rest}=this.props;warning(wrapClassName===undefined,'wrapClassNameisdeprecated,pleaseuseclassNameinstead.');consthaveMask=rest.mask?"":"no-mask";this.parentDrawer=value;constoffsetStyle:any={};if(placement==='left'||placement==='right'){offsetStyle.width=width;}else{offsetStyle.height=height;}return(handler={false} {...rest}{...offsetStyle}open={this.props.visible}onMaskClick={this.onMaskClick}showMask={this.props.mask}placement={placement}style={this.getRcDrawerStyle()}className={classNames(wrapClassName,className,haveMask)}>{this.renderBody()});}render(){return({this.renderProvider} );}完整代码可以参考此处
米脂
相关分类