mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix: fix the leaf hoc component fails to monitor Node changes, and modify the logic for get node
This commit is contained in:
parent
3d41fd5d07
commit
6ee6b07a10
@ -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 = [];
|
||||
|
||||
@ -18,7 +18,9 @@ exports[`children this.props.children is array 1`] = `
|
||||
exports[`lifecycle leaf change and make componentWillReceiveProps 1`] = `
|
||||
<div>
|
||||
<div
|
||||
__id="text6"
|
||||
__tag="222"
|
||||
componentId="text6"
|
||||
content="content new leaf"
|
||||
>
|
||||
content new leaf
|
||||
|
||||
@ -193,9 +193,10 @@ describe('lifecycle', () => {
|
||||
|
||||
it('leaf change and make componentWillReceiveProps', () => {
|
||||
const newTextNodeLeaf = new Node(textSchema);
|
||||
nodeMap.set(textSchema.id, newTextNodeLeaf);
|
||||
component.update((
|
||||
<Div _leaf={DivNode}>
|
||||
<Text _leaf={newTextNodeLeaf} __tag="222" content="content 123"></Text>
|
||||
<Text componentId={textSchema.id} __tag="222" content="content 123"></Text>
|
||||
</Div>
|
||||
));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user