mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
fix(react): present and dismiss hooks return promises (#24299)
This commit is contained in:
@ -14,12 +14,12 @@ export function useIonAlert(): UseIonAlertResult {
|
||||
const present = useCallback(
|
||||
(messageOrOptions: string | (AlertOptions & HookOverlayOptions), buttons?: AlertButton[]) => {
|
||||
if (typeof messageOrOptions === 'string') {
|
||||
controller.present({
|
||||
return controller.present({
|
||||
message: messageOrOptions,
|
||||
buttons: buttons ?? [{ text: 'Ok' }],
|
||||
});
|
||||
} else {
|
||||
controller.present(messageOrOptions);
|
||||
return controller.present(messageOrOptions);
|
||||
}
|
||||
},
|
||||
[controller.present]
|
||||
@ -35,15 +35,15 @@ export type UseIonAlertResult = [
|
||||
* @param message The main message to be displayed in the alert
|
||||
* @param buttons Optional - Array of buttons to be added to the alert
|
||||
*/
|
||||
(message: string, buttons?: AlertButton[]): void;
|
||||
(message: string, buttons?: AlertButton[]): Promise<void>;
|
||||
/**
|
||||
* Presents the alert
|
||||
* @param options The options to pass to the IonAlert
|
||||
*/
|
||||
(options: AlertOptions & HookOverlayOptions): void;
|
||||
(options: AlertOptions & HookOverlayOptions): Promise<void>;
|
||||
},
|
||||
/**
|
||||
* Dismisses the alert
|
||||
*/
|
||||
() => void
|
||||
() => Promise<void>
|
||||
];
|
||||
|
Reference in New Issue
Block a user