Basaingeal / Razor.SweetAlert2

A Razor class library for interacting with SweetAlert2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'CurrieTechnologies' was undefined Error

FernandoGPinto opened this issue · comments

I'm using blazor wasm, registered the sweet alert service in Program.cs, added the sweet alert script below the framework script as indicated and injected the SweetAlertService into a component but when trying to call FireAsync() I'm getting the following exception:

Microsoft.JSInterop.JSException: Could not find 'CurrieTechnologies.Razor.SweetAlert2.FireSettings' ('CurrieTechnologies' was undefined).
Error: Could not find 'CurrieTechnologies.Razor.SweetAlert2.FireSettings' ('CurrieTechnologies' was undefined).

I am also unable to inject SweetAlertService into a component without the @using CurrieTechnologies.Razor.SweetAlert2 directive.

Hmmm, which version of .net you are using?

I have certainly crashed randomly into this error when running under mobile blazor bindings but still don't know if is a bug of mbb deployment or this library...

The funny thing is that only happends to me with this library

I can think there is maybe a possible bug

Maybe you can try uploading a repro of this error and give @Basaingeal a chance to take a look?

Sorry @FernandoGPinto, I'm not able to reproduce this on my own .NET 5 WASM sample project. If you could create a minimal reproduction repo, I could take a look at that as was suggested.

As for @using CurrieTechnologies.Razor.SweetAlert2, you're right, you do need that, but you can stick it in your _Imports.razor file to not have to add it in each time.

Hi @Basaingeal, I haven't responded earlier because the error went away without any changes being made and I was trying to figure out whether it was a temporary fluke. It seems that it wasn't and I haven't encountered the error since.

@FernandoGPinto maybe you can close this issue then?

I had this issue, or similar.
This is because the the JS interopt of the webcomponent didn't download intro my browser.

Setting 'no cache' in the network section of my browser's inspector force to download this js file.

Then it works.

@FernandoGPinto, this would explain that it worked somehow, and then you do not have anymore issue. Your browser might dowload this js file.

I really need to understand how cache is working in blazor or pwa... this is still mysterious for me and this is 90% of my bug issues !

For me, this error is present in Chrome but in Edge works fine

I was able to solve this problem. Solution: Add "defer" keyword at script line. Now, it works fine in Chrome and Edge

<script src="_content/CurrieTechnologies.Razor.SweetAlert2/sweetAlert2.min.js" defer></script>