question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue3: issues when working with args in stories

See original GitHub issue

Describe the bug This is a follow up to some changes I introduced in this PR: https://github.com/storybookjs/storybook/pull/15168

While working with the new released version 6.3.0 in a project, I found some issues when working with args/props in story components:

  • Args get passed the the component regardless of using v-bind="args"
  • No way of overwriting specific args in setup or on the component itself
  • Passing a subset of args to the component does not work

I created a component which demonstrates all theses issues over here: https://github.com/thomasaull/storybook-args-bugs/blob/master/src/stories/BugProps.stories.js

Theses issued do not happen with 6.2.9, so they are probably related to the PR I mentioned above.

I tried to reintroduce the way props/args were handled before the changes in this PR: https://github.com/storybookjs/storybook/pull/13981 and this fixes all the issues I mentioned abvoe and the problem with the full re-render on args update (https://github.com/storybookjs/storybook/issues/13913) aswell. So, in my opinion it would make sense to go back to using this method of handling args/props… The downside is, this would introduce some breaking changes:

Before:

const Template = (args) => ({
  components: { MyComponent },
  setup() {
    return { args };
  },
  template: '<MyComponent v-bind="args"/>',
});

After:

const Template = (args, { argTypes }) => ({
  components: { MyComponent },
  props: Object.keys(argTypes),
  template: '<MyComponent v-bind="$props"/>',
});

The amount of boilerplate code necessary wouldn’t change, just the way the stories are defined (It’d be basically the same way it’s handled with vue2)

Edit: Found one issue so far with the reintroduced code before https://github.com/storybookjs/storybook/pull/13981:

  • Using inject in a decorator does not seem to work Got it working ✅

To Reproduce

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Jun 30, 2021

Yowza!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.2 containing PR #15409 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade
1reaction
shilmancommented, Jun 29, 2021

IMO using the vue3 setup method is strictly an improvement over the vue2 args technique. Vue2 automagically maps the args passed into your story function into a reactive store, so there is no way for the user to manually curate the values of the args. The setup function is a natural and “vue3-native” way to explicitly create that mapping.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue 3 Router Addon | Storybook: Frontend workshop for UI ...
A Storybook decorator that allows you to build stories for your routing-aware components.
Read more >
How to Set Up Storybook in VueJS - This Dot Labs
How to setup Storybook in VueJS In this post, we will take a look at how to setup storybook in our VueJS application....
Read more >
Dynamically updating args in Storybook from a Vue component
The trouble with it being a decorator is that you can't directly access it within a story so first we have to make...
Read more >
Property 'args' does not exist on type (args: Props)
types/types' import { Meta, Story } from '@storybook/vue3' export default { title: 'Example/Button', component: Button, ...
Read more >
Vue 3 was a mistake that we should not repeat - Medium
The argument is that most of them including composition API, teleport, suspense etc. already work with Vue 2 so they can't really be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found