Storybook js conditional controls breaking code preview?

127 Views Asked by At

I am using https://storybook.js.org/docs/react/essentials/controls#conditional-controls in a react component, but when I add if: to the default story, clicking on 'show code' shows me the args as an object, not the <SomeComponent /> component code.

Here is what I have for the conditionals in the story

thing1: {
   if: {
       arg: 'hasThing',
   },
   control: {type: 'text'},
},
thing2: {
    if: {
        arg: 'hasThing',
        truthy: false,
    },
    control: {type: 'text'},
},
thing3: {
    if: {
        arg: 'isAnotherThing',  
    },
    options: ['yes', 'no'],
    control: {type: 'select'},
},

When removing the above code, the code preview works as expected, I get back <SomeComponent />

0

There are 0 best solutions below