Skip to content

Commit 6ee6b07

Browse files
liujupingLeoYuan
authored andcommitted
fix: fix the leaf hoc component fails to monitor Node changes, and modify the logic for get node
1 parent 3d41fd5 commit 6ee6b07

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/renderer-core/src/hoc/leaf.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { EngineOptions } from '@alilc/lowcode-editor-core';
55
import { debounce } from '../utils/common';
66
import adapter from '../adapter';
77
import * as types from '../types/index';
8-
import { parseData } from '../utils';
98

109
export interface IComponentHocInfo {
1110
schema: any;
@@ -363,12 +362,12 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
363362
};
364363

365364
componentWillReceiveProps(nextProps: any) {
366-
let { _leaf, componentId } = nextProps;
365+
let { componentId } = nextProps;
367366
if (nextProps.__tag === this.props.__tag) {
368367
return null;
369368
}
370369

371-
_leaf = _leaf || getNode?.(componentId);
370+
const _leaf = getNode?.(componentId);
372371
if (_leaf && this.curEventLeaf && _leaf !== this.curEventLeaf) {
373372
this.disposeFunctions.forEach((fn) => fn());
374373
this.disposeFunctions = [];

‎packages/renderer-core/tests/hoc/__snapshots__/leaf.test.tsx.snap‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ exports[`children this.props.children is array 1`] = `
1818
exports[`lifecycle leaf change and make componentWillReceiveProps 1`] = `
1919
<div>
2020
<div
21+
__id="text6"
2122
__tag="222"
23+
componentId="text6"
2224
content="content new leaf"
2325
>
2426
content new leaf

‎packages/renderer-core/tests/hoc/leaf.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ describe('lifecycle', () => {
193193

194194
it('leaf change and make componentWillReceiveProps', () => {
195195
const newTextNodeLeaf = new Node(textSchema);
196+
nodeMap.set(textSchema.id, newTextNodeLeaf);
196197
component.update((
197198
<Div _leaf={DivNode}>
198-
<Text _leaf={newTextNodeLeaf} __tag="222" content="content 123"></Text>
199+
<Text componentId={textSchema.id} __tag="222" content="content 123"></Text>
199200
</Div>
200201
));
201202

0 commit comments

Comments
 (0)