Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) type error #111

Closed
MotionPhix opened this issue Apr 11, 2023 · 5 comments · Fixed by #112
Closed

Uncaught (in promise) type error #111

MotionPhix opened this issue Apr 11, 2023 · 5 comments · Fixed by #112

Comments

@MotionPhix
Copy link

After setting up package really well but my notifications were still not working. I am using Laravel 10 and php 8.2. I am getting an error that just says Uncaught (in promise) TypeError: i is not a function at module.esm.js:1053:28. Anyone with a possible working solution? I am using Inertiajs and Laravel

@GamendeBrian
Copy link

I'm getting the same error.
For me, it conflicts with AlpineJS.
It seems like it's related to this issue: https://laracasts.com/discuss/channels/livewire/livewire-modal-freezing-page

The issue doesn't remain when I remove the @notifyJs helper from my layout file.
Notifying does still work after removing it.

@akunbeben
Copy link
Contributor

akunbeben commented Apr 14, 2023

I got the same Issue today, the root problem is. The package started a new instance of AlpineJS and replaced the previous AlpineJS instance that was called from app.js. Here 👇🏻

import Alpine from 'alpinejs'
const notification = document.querySelector('div.notify')
if (notification) {
setTimeout(() => {
notification.remove()
}, notify.timeout )
}
window.Alpine = Alpine
Alpine.start()

The quick solution is, to remove the @notifyJs line from your layout. Then copy this code

const notification = document.querySelector('div.notify')
if (notification) {
setTimeout(() => {
notification.remove()
}, notify.timeout )
}

And paste to your main js app.js

Details

code

For a long-term solution, I think someone should create a PR to add the ability to load Alpine conditionally. Or @mckenziearts can do that.

@MotionPhix
Copy link
Author

Hello, @akunbeben, thanks for your prompt response. While the solution you showed me works, I still got one issue where the toast does not show up when it's supposed to. Like I have to refresh the page for the toast to show up which beats the whole purpose of having a toast in the first place. Is this something you have ever come across or it's an issue with my setup?

@akunbeben
Copy link
Contributor

You can't achieve that by default, using this package. This package only pushes the toast (message) to the sessions and doesn't have a listener that are listening for the toast message.

An easy way, you can use other packages such as Filament/Notifications, etc.
The hard way, create a broadcast event and listen to it using laravel echo.

@GamendeBrian
Copy link

@MotionPhix, another alternative I found was TALL Toasts.

I also struggled with the event not listening, without adding functionality myself to listen to the event.

Hopefully with a newer release of this package, it has a built-in event listener hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants