Storybook: @storybook/addon-controls with vuejs, component reactive in docs while not reactive in canvas

Created on 10 Jul 2020  路  2Comments  路  Source: storybookjs/storybook

My component is reactive only in Docs tab.

My story

export default {
  title: "WCtaButton",
  component: WCtaButton,
  argTypes: {
    url: { control: 'text' },
    cta: { control: 'text' },
  }
}

export const defaultState = (args) => {
  console.log(args)
  return ({
    components: { WCtaButton },
    template: `<div :style="style">
    <w-cta-button v-bind="props"/>
    </div>`,
    data() {
      return {
        style: {
          height: '10em',
          border: '1px solid'
        }
      }
    },
    computed: {
      props() {
        return args
      }
    },
    mounted() {
      console.log('mounted')
    }
  })
};
defaultState.args = adapter(manifest)

Controls are populated correctly, defaults included. Though when I start typing the component doesn't update

image

I can see the args, being logged on each input event, but component doesn't get remounted

image

If I switch tab to Docs, I can immediately see my latest input being rendered, and when I type in more the component is reactive.

image

Also, I see that here the component is remounted on each input event

image

Am I doing anything wrong?

System info
Environment Info:

System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-2700K CPU @ 3.50GHz
Binaries:
Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.1 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.8.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.18362.449.0
npmPackages:
@storybook/addon-a11y: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-actions: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-controls: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-docs: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-links: >=6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-storysource: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/addon-viewport: ^6.0.0-rc.1 => 6.0.0-rc.1
@storybook/vue: ^6.0.0-rc.1 => 6.0.0-rc.1

controls vue question / support

Most helpful comment

Yes, that works, thank you!

Seems like props: Object.keys(args), is necessary for reactivity.

thank you

All 2 comments

Yes, that works, thank you!

Seems like props: Object.keys(args), is necessary for reactivity.

thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rpersaud picture rpersaud  路  3Comments

arunoda picture arunoda  路  3Comments

levithomason picture levithomason  路  3Comments

shilman picture shilman  路  3Comments

sakulstra picture sakulstra  路  3Comments