fix: default FaultComponent can not get componentName (#2385)

This commit is contained in:
Rainke 2023-08-18 15:01:11 +08:00 committed by GitHub
parent 82ecee98c5
commit 4128654347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,17 +135,20 @@ export default function rendererFactory(): IRenderComponent {
return engine.createElement(engine.getFaultComponent(), { return engine.createElement(engine.getFaultComponent(), {
...this.props, ...this.props,
error: this.state.error, error: this.state.error,
componentName: this.props._componentName
}); });
} }
return originRender.call(this); return originRender.call(this);
}; };
const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate; if(!(SetComponent.prototype instanceof PureComponent)) {
SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) { const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate;
if (nextState && nextState.engineRenderError) { SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) {
return true; if (nextState && nextState.engineRenderError) {
} return true;
return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true; }
}; return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
};
}
} }
createElement(SetComponent: any, props: any, children?: any) { createElement(SetComponent: any, props: any, children?: any) {