mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +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 { debounce } from '../utils/common';
|
||||||
import adapter from '../adapter';
|
import adapter from '../adapter';
|
||||||
import * as types from '../types/index';
|
import * as types from '../types/index';
|
||||||
import { parseData } from '../utils';
|
|
||||||
|
|
||||||
export interface IComponentHocInfo {
|
export interface IComponentHocInfo {
|
||||||
schema: any;
|
schema: any;
|
||||||
@ -363,12 +362,12 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps: any) {
|
componentWillReceiveProps(nextProps: any) {
|
||||||
let { _leaf, componentId } = nextProps;
|
let { componentId } = nextProps;
|
||||||
if (nextProps.__tag === this.props.__tag) {
|
if (nextProps.__tag === this.props.__tag) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_leaf = _leaf || getNode?.(componentId);
|
const _leaf = getNode?.(componentId);
|
||||||
if (_leaf && this.curEventLeaf && _leaf !== this.curEventLeaf) {
|
if (_leaf && this.curEventLeaf && _leaf !== this.curEventLeaf) {
|
||||||
this.disposeFunctions.forEach((fn) => fn());
|
this.disposeFunctions.forEach((fn) => fn());
|
||||||
this.disposeFunctions = [];
|
this.disposeFunctions = [];
|
||||||
|
|||||||
@ -18,7 +18,9 @@ exports[`children this.props.children is array 1`] = `
|
|||||||
exports[`lifecycle leaf change and make componentWillReceiveProps 1`] = `
|
exports[`lifecycle leaf change and make componentWillReceiveProps 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
|
__id="text6"
|
||||||
__tag="222"
|
__tag="222"
|
||||||
|
componentId="text6"
|
||||||
content="content new leaf"
|
content="content new leaf"
|
||||||
>
|
>
|
||||||
content new leaf
|
content new leaf
|
||||||
|
|||||||
@ -193,9 +193,10 @@ describe('lifecycle', () => {
|
|||||||
|
|
||||||
it('leaf change and make componentWillReceiveProps', () => {
|
it('leaf change and make componentWillReceiveProps', () => {
|
||||||
const newTextNodeLeaf = new Node(textSchema);
|
const newTextNodeLeaf = new Node(textSchema);
|
||||||
|
nodeMap.set(textSchema.id, newTextNodeLeaf);
|
||||||
component.update((
|
component.update((
|
||||||
<Div _leaf={DivNode}>
|
<Div _leaf={DivNode}>
|
||||||
<Text _leaf={newTextNodeLeaf} __tag="222" content="content 123"></Text>
|
<Text componentId={textSchema.id} __tag="222" content="content 123"></Text>
|
||||||
</Div>
|
</Div>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user