Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

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

@Richacinas

Description

@Richacinas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions