mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-04-18 22:00:22 +08:00
fix: set slot to different types depend on slot children's num
when only one child in slot, set slot to ReactElement instead of array
This commit is contained in:
parent
b28fbce8ab
commit
823fac1766
@ -150,15 +150,17 @@ const _ImplWrapper = React.forwardRef<HTMLDivElement, ImplWrapperProps>((props,
|
||||
if (!childrenMap[c.id]) {
|
||||
return {};
|
||||
}
|
||||
const res: Record<string, React.ReactElement[]> = {};
|
||||
const res: Record<string, React.ReactElement[] | React.ReactElement> = {};
|
||||
for (const slot in childrenMap[c.id]) {
|
||||
res[slot] = childrenMap[c.id][slot].map(child => {
|
||||
const slotChildren = childrenMap[c.id][slot].map(child => {
|
||||
if (!childrenCache.get(child)) {
|
||||
const ele = <ImplWrapper key={child.id} {...props} component={child} />;
|
||||
childrenCache.set(child, ele);
|
||||
}
|
||||
return childrenCache.get(child)!;
|
||||
});
|
||||
|
||||
res[slot] = slotChildren.length === 1 ? slotChildren[0] : slotChildren;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user