refactor: fix compiling (#44616)

* refactor: fix compiling

* perf: code logic update
This commit is contained in:
MadCcc 2023-09-04 17:20:30 +08:00 committed by GitHub
parent 85dc67f1cc
commit b284648f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 36 deletions

View File

@ -32,23 +32,21 @@ const ConfirmCancelBtn: FC = () => {
onCancel,
onConfirm,
} = useContext(ModalContext);
return (
mergedOkCancel && (
<ActionButton
isSilent={isSilent}
actionFn={onCancel}
close={(...args: any[]) => {
close?.(...args);
onConfirm?.(false);
}}
autoFocus={autoFocusButton === 'cancel'}
buttonProps={cancelButtonProps}
prefixCls={`${rootPrefixCls}-btn`}
>
{cancelTextLocale}
</ActionButton>
)
);
return mergedOkCancel ? (
<ActionButton
isSilent={isSilent}
actionFn={onCancel}
close={(...args: any[]) => {
close?.(...args);
onConfirm?.(false);
}}
autoFocus={autoFocusButton === 'cancel'}
buttonProps={cancelButtonProps}
prefixCls={`${rootPrefixCls}-btn`}
>
{cancelTextLocale}
</ActionButton>
) : null;
};
export default ConfirmCancelBtn;

View File

@ -68,25 +68,23 @@ export const Footer: React.FC<
const btnCtxValueMemo = React.useMemo(() => btnCtxValue, [...Object.values(btnCtxValue)]);
const footerOriginNode = (
<>
<NormalCancelBtn />
<NormalOkBtn />
</>
);
return footer === undefined || typeof footer === 'function' ? (
<DisabledContextProvider disabled={false}>
let footerNode;
if (typeof footer === 'function' || typeof footer === 'undefined') {
footerNode = (
<ModalContextProvider value={btnCtxValueMemo}>
{typeof footer === 'function'
? footer(footerOriginNode, {
OkBtn: NormalOkBtn,
CancelBtn: NormalCancelBtn,
})
: footerOriginNode}
<NormalCancelBtn />
<NormalOkBtn />
</ModalContextProvider>
</DisabledContextProvider>
) : (
footer
);
);
if (typeof footer === 'function') {
footerNode = footer(footerNode, {
OkBtn: NormalOkBtn,
CancelBtn: NormalCancelBtn,
});
}
} else {
footerNode = footer;
}
return <DisabledContextProvider disabled={false}>{footerNode}</DisabledContextProvider>;
};