chore: confirmBox 的 onConfirm 也可能是异步的 如果存在异步错误也需要捕获 (#5856)

* chore: confirmBox 的 onConfirm 也可能是异步的 如果存在异步错误也需要捕获

* 下发 loading
This commit is contained in:
liaoxuezhi 2022-12-08 15:29:34 +08:00 committed by GitHub
parent 41319213ee
commit 70665092c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ export interface ConfirmBoxProps extends LocaleProps, ThemeProps {
children?:
| JSX.Element
| ((methods: {
loading?: boolean;
bodyRef: React.MutableRefObject<
| {
submit: () => Promise<Record<string, any>>;
@ -77,7 +78,7 @@ export function ConfirmBox({
return;
}
onConfirm?.(ret);
await onConfirm?.(ret);
} catch (e) {
setError(e.message);
} finally {
@ -103,7 +104,8 @@ export function ConfirmBox({
<Modal.Body className={bodyClassName}>
{typeof children === 'function'
? children({
bodyRef: bodyRef
bodyRef: bodyRef,
loading
})
: children}
</Modal.Body>