mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
refactor: fix compiling (#44616)
* refactor: fix compiling * perf: code logic update
This commit is contained in:
parent
85dc67f1cc
commit
b284648f11
@ -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;
|
||||
|
@ -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>;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user