fix(react): present and dismiss hooks return promises (#24299)

This commit is contained in:
Sean Perkins
2021-12-01 15:16:55 -05:00
committed by GitHub
parent e41b0e0cf2
commit 4b26feaa47
5 changed files with 25 additions and 25 deletions

View File

@ -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>
];