Skip to content

How to update args after button click? Storybook 8, Vue 3, Vite #29265

Closed Answered by lucaplus
pellexa asked this question in Help
Discussion options

You must be logged in to vote

Hi,
I was not able to use useArgs, I got your same error.

This link helped me find a solution:
https://craigbaldwin.com/blog/updating-args-storybook-vue/

The workaround was to make it available through a decorator. I was using Storybook 8.4.7.

In preview.ts you add a decorator:

import { useArgs } from '@storybook/client-api'

export const decorators = [
  (story, context) => {
    const [_, updateArgs] = useArgs()
    return story({ ...context, updateArgs })
  },
]

Then in your render function or Template of your Story you can access the updateArgs function to update the args of the Story so they are reflected in the controls panel of Storybook:

export const metaVue: MetaVue<typeof Table> = 

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pellexa
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants