Search code examples
sweetalert2

sweetalert2 TypeError: this is undefined after v8 upgrade


I moved from sweetalert2 ^7.32.4 → ^8.11.7, I read the v8.0.0 breaking changes and none of my code directly call one of the impacted functions.

I wonder what is causing this mysterious error: (TypeError: this is undefined)

enter image description here


Solution

  • I went to see the new documentation examples, and they are all launching the popup with Swal.fire() when before Swal() alone was valid.

    The problem is that if you check CHANGELOG.md for fire you don't see any mentions of that function. But this is a breaking change as it was earlier not mandatory and now is.

    Here is the fix for my specific problem.