Skip to content

dialogs()

function dialogs(onDialog): HookExtension<HookEvent<"alert" | "confirm" | "prompt", Dialog>>;

Answers the page's alert, confirm and prompt with onDialog instead of the native dialogs; the page waits for the answer.

Not in react-native-webview, whose dialogs are native.

The return value (a promise is awaited) is the answer: true accepts a confirm, a string is a prompt's text, and anything else, a throw too, dismisses the dialog (confirm false, prompt null). An alert's answer doesn't matter.

signal aborts when the core stops waiting for the answer, and the dialog is then dismissed; HookExtension.onAsk has the rules.

Without this extension, the default dialogs show, as WebViewProps describes.

Parameters

Parameter Type
onDialog (dialog, signal) => unknown

Returns

HookExtension<HookEvent<"alert" | "confirm" | "prompt", Dialog>>