tv-toast icon indicating copy to clipboard operation
tv-toast copied to clipboard

Nuxt process client

Open popovicieduard opened this issue 4 years ago • 3 comments

In nuxt if I call the this.$toast.show('foo') it will throw an error: Cannot read property 'show' of undefined, this is because window is not present on ssr, specifying mode: 'client' in nuxt.config.js doesn't work, so the only thing to avoid this is to check for process.client every time I call this.$toast.show, is there a way to asbtract this? so that I don't have to create ifs everytime?

popovicieduard avatar Jan 11 '21 20:01 popovicieduard

@popovicieduard are you able to share your repo/config/sample so i can duplicate this? that should help me whip up a fix

acidjazz avatar Jan 11 '21 23:01 acidjazz

It seems that the error only throws inside asyncData, which is why the windows is not available, it works as intended in setup function, thank you anyways, I don't think this is a relevant issue, you could duplicate this by calling this.$toast.show() inside asyncData

popovicieduard avatar Jan 12 '21 15:01 popovicieduard

@popovicieduard hmm yea, i'm not sure this is an issue i can address w/ in this module, i think you'd have to set something inside there that fires the toast when the code client-side gets reached.. maybe set something in data() that you can pick up and send to toasts in mounted or created? somewhere you can check that you're in the browser?

acidjazz avatar Jan 12 '21 19:01 acidjazz