Notification on React not working

Hey there!

Thanks for a great set of tools. Got so much done already within a couple of days… <3

I’m using the react version and have difficulties to get the notification toaster to show up. It runs the event handler function but nothing is visible. Here’s the code:

    console.log('it runs')
    const app = this.$f7
    console.log(app)
    app.notification.create({
      icon: '<i class="icon demo-icon">7</i>',
      title: 'Framework7',
      titleRightText: 'now',
      subtitle: 'Notification with close on click',
      text: 'Click me to close',
      closeOnClick: true
    })

So I can see that console logs “it runs”. Then the app is logged as the entire constructed object with the notification object under and then the create function within that - as the API app.notification.create({}) suggests.

But nothing is shown.

Any thoughts?

OK, I was almost there. Apparently, we just need to open it after creation.

This works perfectly:

const app = this.$f7
const notification = app.notification.create({
    icon: '<i class="icon demo-icon">7</i>',
    title: 'Framework7',
    subtitle: 'Notification with close on click',
    text: 'Click me to close',
    closeOnClick: true
})
notification.open()
3 Likes