storybook-eol/addon-smart-knobs

PropTypes.oneOf in default props is breaking the rest of properties.

Richacinas opened this issue · 0 comments

I have a Button component. Here is the PropTypes section:

Button.defaultProps = {
  disabled: false,
  hidden: false,
  small: false,
  block: false,
  blockMax: false,
  icon: undefined,
  squaredMobile: false,
  simple: false,
  subtype: 'primary',
};

Button.propTypes = {
  disabled: PropTypes.bool,
  hidden: PropTypes.bool,
  small: PropTypes.bool,
  block: PropTypes.bool,
  blockMax: PropTypes.bool,
  icon: PropTypes.string,
  onClick: PropTypes.func,
  squaredMobile: PropTypes.bool,
  simple: PropTypes.bool,
  subtype: PropTypes.oneOf(['primary', 'alt', 'nude', 'outline', 'outline-alt']),
};

This way, my Smart Knobs is showing all of these properties with the different inputs and toggles working great.

If I move my defaultProps and put a oneOf property before any other type of property, like this:

Button.defaultProps = {
  subtype: 'primary',
  disabled: false,
  hidden: false,
  small: false,
  block: false,
  blockMax: false,
  icon: undefined,
  squaredMobile: false,
  simple: false,
};

The only properties that Smart Knobs will render will be the ones before any OneOf property and that property included. In this case, I can only see subtype property.