Skip to content
This repository has been 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

Open
Richacinas opened this issue Jun 12, 2019 · 0 comments
Open

Comments

@Richacinas
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant