Describe the bug
When changing the values of an object rendered through @storybook/addon-knobs, the UI disappears.
To Reproduce
object using addon-knobsnpm run storybookobject values in the Storybook knobs tabobject disappearsExpected behavior
The object values should be editable from within the Storybook UI without the knob disappearing.
Screenshots

Code snippets
Working example here: https://github.com/benjarwar/storybook-knobs-object-test
npm inpm run storybookSystem:
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
Yarn: 1.21.1 - ~/.nvm/versions/node/v8.15.1/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v8.15.1/bin/npm
Browsers:
Chrome: 79.0.3945.130
Firefox: 72.0.1
Safari: 13.0.5
npmPackages:
@storybook/addon-actions: ^5.3.14 => 5.3.14
@storybook/addon-knobs: ^5.3.14 => 5.3.14
@storybook/addon-links: ^5.3.14 => 5.3.14
@storybook/addons: ^5.3.14 => 5.3.14
@storybook/react: ^5.3.14 => 5.3.14
The problem here is you are not creating the object knob inside the story function. If you change your example to something like this you should be all set:
export const Ctas = () => {
const value = object(label, defaultValue);
return (
<div>
<div>
<h3>CTA</h3>
<Cta href="#primary-cta" type="Primary">
{text("Primary CTA Label", "Primary CTA")}
{value.foo}
</Cta>
</div>
</div>
);
};
Ah, thanks @jonspalmer. That indeed did the trick, and makes sense.
Most helpful comment
The problem here is you are not creating the object knob inside the story function. If you change your example to something like this you should be all set: