pocka / storybook-addon-vue-info

Info addon for Vue components
https://storybook-addon-vue-info.netlify.com/?path=/story/examples-basic-usage--simple-example
MIT License
164 stars 28 forks source link

Bug with Vue-i18n #63

Closed throrin19 closed 5 years ago

throrin19 commented 5 years ago

Describe the bug When I try to use your addon in a component with a default value setted by Vue-i18n, I have this basic error :

TypeError: this.$t is not a function

To Reproduce Steps to reproduce the behavior:

  1. Create a component with a default property setted with VueI18n :
    {
        textAdd : {
            type : String,
            default() {
                return this.$t('globalAddItem');
            },
        },
    }
  2. Set StoryBook as decorator in your stories (I have this error with withInfo and the decorator)
  3. Launch storybook
  4. Go to your component page

Expected behavior Use correctly the Vue-i18n extension and know/translate the vue-i18n string

Desktop (please complete the following information):

pocka commented 5 years ago

It seems to be impossible (or too difficult) to get access to component's this from the addon. Closing this issue as wontfix.

But, I know, there are not few cases accessing this in props default. To prevent breaking entire preview, I've added try-catch for getting props default and error messages for them in v1.0.0-alpha.5.

https://deploy-preview-66--storybook-addon-vue-info.netlify.com/?selectedKind=Issues%2F%2363&selectedStory=Should%20display%20error%20message%20when%20failed%20to%20get%20default&full=0&addons=1&stories=1&panelRight=0

If anyone has an idea for resolving the this problem, please comment here. Then I'll reopen this.