Skip to content

Commit

Permalink
fix: default FaultComponent can not get componentName
Browse files Browse the repository at this point in the history
  • Loading branch information
rainke authored Aug 18, 2023
1 parent 82ecee9 commit ff2d73d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/renderer-core/src/renderer/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,20 @@ export default function rendererFactory(): IRenderComponent {
return engine.createElement(engine.getFaultComponent(), {
...this.props,
error: this.state.error,
componentName: this.props._componentName
});
}
return originRender.call(this);
};
const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate;
SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) {
if (nextState && nextState.engineRenderError) {
return true;
}
return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
};
if(!(SetComponent.prototype instanceof PureComponent)) {
const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate;
SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) {
if (nextState && nextState.engineRenderError) {
return true;
}
return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
};
}
}

createElement(SetComponent: any, props: any, children?: any) {
Expand Down

0 comments on commit ff2d73d

Please sign in to comment.