mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-23 18:18:12 +00:00
fix: 🐛 解决 Rax 模式下报错信息丢失的问题
This commit is contained in:
parent
c3bfaf09a9
commit
19d0f1c5ed
@ -111,9 +111,17 @@ export default function rendererFactory() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetComponent.patchedCatch = true;
|
SetComponent.patchedCatch = true;
|
||||||
SetComponent.getDerivedStateFromError = (error: Error) => {
|
|
||||||
return { engineRenderError: true, error };
|
// Rax 的 getDerivedStateFromError 有 BUG,这里先用 componentDidCatch 来替代
|
||||||
|
// @see https://github.com/alibaba/rax/issues/2211
|
||||||
|
const originalDidCatch = SetComponent.prototype.componentDidCatch;
|
||||||
|
SetComponent.prototype.componentDidCatch = function didCatch(this: any, error: Error, errorInfo: any) {
|
||||||
|
this.setState({ engineRenderError: true, error });
|
||||||
|
if (originalDidCatch && typeof originalDidCatch === 'function') {
|
||||||
|
originalDidCatch.call(this, error, errorInfo);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const engine = this;
|
const engine = this;
|
||||||
const originRender = SetComponent.prototype.render;
|
const originRender = SetComponent.prototype.render;
|
||||||
SetComponent.prototype.render = function () {
|
SetComponent.prototype.render = function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user