diff --git a/packages/renderer-core/src/hoc/leaf.tsx b/packages/renderer-core/src/hoc/leaf.tsx index d97140192..d4fa2afef 100644 --- a/packages/renderer-core/src/hoc/leaf.tsx +++ b/packages/renderer-core/src/hoc/leaf.tsx @@ -5,7 +5,6 @@ import { EngineOptions } from '@alilc/lowcode-editor-core'; import { debounce } from '../utils/common'; import adapter from '../adapter'; import * as types from '../types/index'; -import { parseData } from '../utils'; export interface IComponentHocInfo { schema: any; @@ -363,12 +362,12 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, { }; componentWillReceiveProps(nextProps: any) { - let { _leaf, componentId } = nextProps; + let { componentId } = nextProps; if (nextProps.__tag === this.props.__tag) { return null; } - _leaf = _leaf || getNode?.(componentId); + const _leaf = getNode?.(componentId); if (_leaf && this.curEventLeaf && _leaf !== this.curEventLeaf) { this.disposeFunctions.forEach((fn) => fn()); this.disposeFunctions = []; diff --git a/packages/renderer-core/tests/hoc/__snapshots__/leaf.test.tsx.snap b/packages/renderer-core/tests/hoc/__snapshots__/leaf.test.tsx.snap index 253a099c7..e0ddfa8c2 100644 --- a/packages/renderer-core/tests/hoc/__snapshots__/leaf.test.tsx.snap +++ b/packages/renderer-core/tests/hoc/__snapshots__/leaf.test.tsx.snap @@ -18,7 +18,9 @@ exports[`children this.props.children is array 1`] = ` exports[`lifecycle leaf change and make componentWillReceiveProps 1`] = `
content new leaf diff --git a/packages/renderer-core/tests/hoc/leaf.test.tsx b/packages/renderer-core/tests/hoc/leaf.test.tsx index 4539aae45..0e594bc5a 100644 --- a/packages/renderer-core/tests/hoc/leaf.test.tsx +++ b/packages/renderer-core/tests/hoc/leaf.test.tsx @@ -193,9 +193,10 @@ describe('lifecycle', () => { it('leaf change and make componentWillReceiveProps', () => { const newTextNodeLeaf = new Node(textSchema); + nodeMap.set(textSchema.id, newTextNodeLeaf); component.update((
- +
));