Storybook: Boolean default value not showing up in Addon-docs prop table

Created on 12 Jan 2020  路  6Comments  路  Source: storybookjs/storybook

Describe the bug
When using addon:docs prop table for React tsx components the boolean default values don't show up in the table.

To Reproduce

  1. Follow this guide
  2. Add some boolean prop like this:
import React, { FC } from "react";

interface ButtonProps {
  /**
   * Simple click handler
   */
  onClick?: () => void;
  /**
   * Is primary?
   */
  primary: boolean;
}

/**
 * The world's most _basic_ button
 */
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
  <button onClick={onClick} type="button">
    {children}
  </button>
);

Button.defaultProps = {
  primary: true
};
  1. Run yarn storybook and see the result.

72208407-20e97480-349a-11ea-9255-647840810252

Expected behavior
Default values showing up.

System:
System:
OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Node: 10.18.0 - /usr/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.13.4 - /usr/bin/npm
Browsers:
Chrome: 79.0.3945.88
Firefox: 71.0
npmPackages:
@storybook/cli: ^5.3.0 => 5.3.0

docs props bug typescript

Most helpful comment

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.8 containing PR #9560 that references this issue. Upgrade today to try it out!

All 6 comments

@shilman I've looked over this and it appears to be an issue with Docs itself.

The default here is 'false' or 'true'. When testing, all default values come through unless Boolean. My guess is that we need to stringify the values, at least when boolean.

@papeloto are you interested in having a go at this? If not, let me know and I can take a look and make the fix :)

same here, boolean defaultProps disappear after upgrade to 5.3.x

Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.7 containing PR #9525 that references this issue. Upgrade today to try it out!

Closing this issue. Please re-open if you think there's still more to do.

Just upgraded to v5.3.7

image

Now false values don't show up 馃槀

Button.defaultProps = {
  variant: "primary",
  disabled: false,
  type: "button",
  inline: false,
  accessibilityLabel: "Button",
  uppercase: true,
  expand: false
};

Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.0 containing PR #9560 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.8 containing PR #9560 that references this issue. Upgrade today to try it out!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purplecones picture purplecones  路  3Comments

tlrobinson picture tlrobinson  路  3Comments

levithomason picture levithomason  路  3Comments

dnlsandiego picture dnlsandiego  路  3Comments

Jonovono picture Jonovono  路  3Comments