mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 05:48:17 +00:00
fix: 🐛 增加传入组件children的默认值[], 对之前的非健壮组件做兼容
This commit is contained in:
parent
a0ef20756a
commit
af0f2dfc6a
@ -7,7 +7,7 @@ import './renderer.less';
|
|||||||
|
|
||||||
// patch cloneElement avoid lost keyProps
|
// patch cloneElement avoid lost keyProps
|
||||||
const originCloneElement = window.React.cloneElement;
|
const originCloneElement = window.React.cloneElement;
|
||||||
(window as any).React.cloneElement = (child: any, { _leaf, ...props}: any = {}) => {
|
(window as any).React.cloneElement = (child: any, { _leaf, ...props }: any = {}) => {
|
||||||
if (child.ref && props.ref) {
|
if (child.ref && props.ref) {
|
||||||
const dRef = props.ref;
|
const dRef = props.ref;
|
||||||
const cRef = child.ref;
|
const cRef = child.ref;
|
||||||
@ -18,7 +18,7 @@ const originCloneElement = window.React.cloneElement;
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
cRef.current = x;
|
cRef.current = x;
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dRef) {
|
if (dRef) {
|
||||||
@ -27,13 +27,13 @@ const originCloneElement = window.React.cloneElement;
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
dRef.current = x;
|
dRef.current = x;
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
return originCloneElement(child, props);
|
return originCloneElement(child, props);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default class SimulatorRendererView extends Component<{ renderer: SimulatorRenderer }> {
|
export default class SimulatorRendererView extends Component<{ renderer: SimulatorRenderer }> {
|
||||||
render() {
|
render() {
|
||||||
@ -87,7 +87,7 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
|
|||||||
return createElement(
|
return createElement(
|
||||||
Component,
|
Component,
|
||||||
viewProps,
|
viewProps,
|
||||||
children == null ? null : Array.isArray(children) ? children : [children],
|
children == null ? [] : Array.isArray(children) ? children : [children],
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onCompGetRef={(schema: any, ref: ReactInstance | null) => {
|
onCompGetRef={(schema: any, ref: ReactInstance | null) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user