mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 20:48:49 +08:00
chore: confirmBox 的 onConfirm 也可能是异步的 如果存在异步错误也需要捕获 (#5856)
* chore: confirmBox 的 onConfirm 也可能是异步的 如果存在异步错误也需要捕获 * 下发 loading
This commit is contained in:
parent
41319213ee
commit
70665092c1
@ -17,6 +17,7 @@ export interface ConfirmBoxProps extends LocaleProps, ThemeProps {
|
|||||||
children?:
|
children?:
|
||||||
| JSX.Element
|
| JSX.Element
|
||||||
| ((methods: {
|
| ((methods: {
|
||||||
|
loading?: boolean;
|
||||||
bodyRef: React.MutableRefObject<
|
bodyRef: React.MutableRefObject<
|
||||||
| {
|
| {
|
||||||
submit: () => Promise<Record<string, any>>;
|
submit: () => Promise<Record<string, any>>;
|
||||||
@ -77,7 +78,7 @@ export function ConfirmBox({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onConfirm?.(ret);
|
await onConfirm?.(ret);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(e.message);
|
setError(e.message);
|
||||||
} finally {
|
} finally {
|
||||||
@ -103,7 +104,8 @@ export function ConfirmBox({
|
|||||||
<Modal.Body className={bodyClassName}>
|
<Modal.Body className={bodyClassName}>
|
||||||
{typeof children === 'function'
|
{typeof children === 'function'
|
||||||
? children({
|
? children({
|
||||||
bodyRef: bodyRef
|
bodyRef: bodyRef,
|
||||||
|
loading
|
||||||
})
|
})
|
||||||
: children}
|
: children}
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
Loading…
Reference in New Issue
Block a user