yariksav / vuetify-dialog

Easy dialogs in Vuetify.js framework
MIT License
195 stars 48 forks source link

Problem using with nuxt: cannot destructure property 'message' of '$dialog' as it is undefined #144

Open MarceloLuis1997 opened 2 years ago

MarceloLuis1997 commented 2 years ago

Hi!

I'm having some problems using this plugin with Nuxt + Vuetify + @nuxtjs/composition-api. Sometimes it just not work, showing the error: cannot destructure property 'message' of '$dialog' as it is undefined

// composables/dialog.js
import { useContext } from '@nuxtjs/composition-api'

export function useDialog () {
  const { $dialog } = useContext()
  const { message, error, info, warning, notify } = $dialog

  function showInfo (title, text) {
    return info({ title, text })
  }

  function messageSuccess (text) {
    return message.success(text)
  }

  // ... some other functions with message, error, info, warning

  return {
    $dialog,
    showInfo,
    messageSuccess,
    // ...
  }
}

It works randomly, sometimes it works and other times the error appears. It happens on development environment and in production.