I am trying to get a function to excecute after clicking a confirmation button in a Sweet Alert component yet it does not excecute on the first try, I have to click again and then it will excecute, can't figure out why.
function initialize(){setFundir(true) //Esta es la función del Funditrón OJO QUE FUNCIONA
while (fundir) {
console.log("Ejecutando Funditrón")
}}
function executeFunditron() {
Swal.fire({
title: '¿Seguro?',
text: "Esto va a hacer que ésta computadora se realentice al punto de no funcionar.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ejecutar Funditrón',
cancelButtonText: "Cancelar"
}).then((result) => {
if (result.isConfirmed) {
Swal.fire(
'Ejecutando Funditrón',
'Que la Fuerza te acompañe.',
'success',
)
}
}).finally(()=> initialize())
}
No idea what I am doing wrong, I tried putting it inside the component, outside, I used then, no parenthesis, yes parenthesis, this is good.