Skip to main content

Simple Usage

Use the dialogs is almost like use the dialogs native function (alert, confirm and prompt).

tip

All dialog function will return an Promise that only resolves when the user interacts with the dialog, so you can wait for the user interaction to continue your code execution.

Alert Dialog

import { simpleAlert } from 'react-simple-dialogs'

const showAlert = async () => {
await simpleAlert("You can't do this right now.")

console.log('Alert closed')
}

Confirm Dialog

import { simpleConfirm } from 'react-simple-dialogs'

const showConfirmation = async () => {
if (await simpleConfirm('Please confirm something')) {
console.log('Confirmed! 😄')
} else {
console.log('Not confirmed. 🥲')
}
}

Prompt Dialog

import { simplePrompt } from 'react-simple-dialogs'

const showPrompt = async () => {
const name = await simplePrompt('Please inform your name')

console.log(`User name is ${name || 'a mistery'}`)
}