diff --git a/packages/ui/pop-confirm/src/use-pop-confirm.ts b/packages/ui/pop-confirm/src/use-pop-confirm.ts index 272ae49fa..1a28cd324 100644 --- a/packages/ui/pop-confirm/src/use-pop-confirm.ts +++ b/packages/ui/pop-confirm/src/use-pop-confirm.ts @@ -23,17 +23,17 @@ export const usePopConfirm = ({ defaultVisible: false, visible: visibleProp, onOpen, - onClose: () => { - onClose?.() - onCancelProp?.() - }, + onClose, }) + const onCancelLatest = useLatestCallback(onCancelProp) + const onCancel = useCallback(() => { + onCancelLatest() if (closeOnCancel) { visibleAction.off() } - }, [closeOnCancel, visibleAction]) + }, [closeOnCancel, visibleAction, onCancelLatest]) const onConfirmLatest = useLatestCallback(onConfirmProp)