MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / useIonAlert

Function useIonAlert

packages/react/src/hooks/useIonAlert.ts:13–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 * @returns Returns the present and dismiss methods in an array
12 */
13export function useIonAlert(): UseIonAlertResult {
14 const controller = useController<AlertOptions, HTMLIonAlertElement>('IonAlert', alertController, defineCustomElement);
15
16 const present = useCallback(
17 (messageOrOptions: string | (AlertOptions & HookOverlayOptions), buttons?: AlertButton[]) => {
18 if (typeof messageOrOptions === 'string') {
19 return controller.present({
20 message: messageOrOptions,
21 buttons: buttons ?? [{ text: 'Ok' }],
22 });
23 } else {
24 return controller.present(messageOrOptions);
25 }
26 },
27 [controller.present]
28 );
29
30 return [present, controller.dismiss];
31}
32
33export type UseIonAlertResult = [
34 {

Callers 1

AlertHookFunction · 0.90

Calls 2

useControllerFunction · 0.90
presentMethod · 0.65

Tested by

no test coverage detected