Skip to content

Commit 4128654

Browse files
authored
fix: default FaultComponent can not get componentName (#2385)
1 parent 82ecee9 commit 4128654

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

packages/renderer-core/src/renderer/renderer.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,20 @@ export default function rendererFactory(): IRenderComponent {
135135
return engine.createElement(engine.getFaultComponent(), {
136136
...this.props,
137137
error: this.state.error,
138+
componentName: this.props._componentName
138139
});
139140
}
140141
return originRender.call(this);
141142
};
142-
const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate;
143-
SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) {
144-
if (nextState && nextState.engineRenderError) {
145-
return true;
146-
}
147-
return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
148-
};
143+
if(!(SetComponent.prototype instanceof PureComponent)) {
144+
const originShouldComponentUpdate = SetComponent.prototype.shouldComponentUpdate;
145+
SetComponent.prototype.shouldComponentUpdate = function (nextProps: IRendererProps, nextState: any) {
146+
if (nextState && nextState.engineRenderError) {
147+
return true;
148+
}
149+
return originShouldComponentUpdate ? originShouldComponentUpdate.call(this, nextProps, nextState) : true;
150+
};
151+
}
149152
}
150153

151154
createElement(SetComponent: any, props: any, children?: any) {

0 commit comments

Comments
 (0)