mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-16 03:18:11 +00:00
fix: cache pre props. to fix cant keep set value
This commit is contained in:
parent
aceb496ec4
commit
59f3ce5b72
@ -218,6 +218,8 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
nodeChildren: null,
|
nodeChildren: null,
|
||||||
childrenInState: false,
|
childrenInState: false,
|
||||||
visible: !hidden,
|
visible: !hidden,
|
||||||
|
nodeCacheProps: {},
|
||||||
|
nodeProps: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,11 +351,11 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
this.curEventLeaf = _leaf;
|
this.curEventLeaf = _leaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
const {
|
||||||
nodeChildren: null,
|
visible,
|
||||||
nodeProps: {},
|
...resetState
|
||||||
childrenInState: false,
|
} = this.defaultState;
|
||||||
});
|
this.setState(resetState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听参数变化 */
|
/** 监听参数变化 */
|
||||||
@ -378,23 +380,22 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.beforeRender(RerenderType.PropsChanged);
|
this.beforeRender(RerenderType.PropsChanged);
|
||||||
|
const state = this.state;
|
||||||
|
const nodeCacheProps = state.nodeCacheProps;
|
||||||
const nodeProps = getProps(node?.export?.(TransformStage.Render) as types.ISchema, scope, Comp, componentInfo);
|
const nodeProps = getProps(node?.export?.(TransformStage.Render) as types.ISchema, scope, Comp, componentInfo);
|
||||||
const preNodeProps = this.state.nodeProps;
|
if (key && !(key in nodeProps) && (key in this.props)) {
|
||||||
const newNodeProps = {
|
|
||||||
...preNodeProps,
|
|
||||||
...nodeProps,
|
|
||||||
};
|
|
||||||
if (key && !(key in newNodeProps) && (key in this.props)) {
|
|
||||||
// 当 key 在 this.props 中时,且不存在在计算值中,需要用 newValue 覆盖掉 this.props 的取值
|
// 当 key 在 this.props 中时,且不存在在计算值中,需要用 newValue 覆盖掉 this.props 的取值
|
||||||
newNodeProps[key] = newValue;
|
nodeCacheProps[key] = newValue;
|
||||||
}
|
}
|
||||||
__debug(`${leaf?.componentName}[${this.props.componentId}] component trigger onPropsChange!`, newNodeProps);
|
__debug(`${leaf?.componentName}[${this.props.componentId}] component trigger onPropsChange!`, nodeProps, nodeCacheProps, key, newValue);
|
||||||
this.setState('children' in nodeProps ? {
|
this.setState('children' in nodeProps ? {
|
||||||
nodeChildren: nodeProps.children,
|
nodeChildren: nodeProps.children,
|
||||||
nodeProps: newNodeProps,
|
nodeProps,
|
||||||
childrenInState: true,
|
childrenInState: true,
|
||||||
|
nodeCacheProps,
|
||||||
} : {
|
} : {
|
||||||
nodeProps: newNodeProps,
|
nodeProps,
|
||||||
|
nodeCacheProps,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -497,6 +498,7 @@ export function leafWrapper(Comp: types.IBaseRenderer, {
|
|||||||
|
|
||||||
const compProps = {
|
const compProps = {
|
||||||
...rest,
|
...rest,
|
||||||
|
...(this.state.nodeCacheProps || {}),
|
||||||
...(this.state.nodeProps || {}),
|
...(this.state.nodeProps || {}),
|
||||||
children: [],
|
children: [],
|
||||||
__id: this.props.componentId,
|
__id: this.props.componentId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user