Closed ThomasGysemans closed 2 years ago
I believe you missed this detail from the docs:
// index.js
- import Swal from 'sweetalert2'
+ import Swal from 'sweetalert2/src/sweetalert2.js'
Let me know if this helped
import Swal from "sweetalert2/src/sweetalert2.js"
is throwing an error:
SyntaxError: Cannot use import statement outside a module
Same if I remove the ".js" extension
That's completely unrelated issue, https://stackoverflow.com/questions/58211880/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-import
All right I had to use this instead:
import Swal from "sweetalert2/dist/sweetalert2.js";
The problem is that this isn't specified in the README of sweetalert2-react-content. It is also false in the repo sweetalert2-themes.
As you are a member, could you change that or should I publish an issue there? Or at least specify it in the READMEs?
That's the Next.js issue: https://github.com/vercel/next.js/issues/9890
But since Next.js is quite popular, I think it does make sense to update the docs. Thanks for the suggestion! Done 👍
My project and steps to reproduce the problem
I want to use SweetAlert with the theme entitled "borderless". I was coding my project with it but I realised it wasn't working, so I built a new nextjs project with the following code:
I have executed the following commands, in that order:
Here is my
package.json
:What's not working?
Swal is working, but the theme is the one by default. I don't know why the borderless theme is not used by Swal whereas it is installed, and the css file is imported in
_app.js
.Expected behavior
I want to have the same behavior as on the documentation when I enable the borderless theme.
Live demo
You can reproduce easily a demo on your own computer, I have written the whole source code above.