swal.mixin(params)
🎉 thanks to @zenflow
Returns a wrapped instance of swal
containing params
as defaults.
Useful for reusing swal configuration.
Before:
const textPromptOptions = { input: 'text', showCancelButton: true }
const {value: firstName} = await swal({ ...textPromptOptions, title: 'What is your first name?' })
const {value: lastName} = await swal({ ...textPromptOptions, title: 'What is your last name?' })
After:
const myTextPrompt = swal.mixin({ input: 'text', showCancelButton: true })
const {value: firstName} = await myTextPrompt('What is your first name?')
const {value: lastName} = await myTextPrompt('What is your last name?')