Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propTypes definition should have default value definition in itself. #10765

Closed
daniloster opened this issue Sep 20, 2017 · 1 comment
Closed

Comments

@daniloster
Copy link

Do you want to request a feature or report a bug?
feature

What is the current behavior?
Defining an optional type in propTypes for components make us define the defaultProps as well.

What is the expected behavior?
Set default value during propTypes definition.

MyComponent.propTypes = {
  className: PropTypes.string.default('MyClass'),
  children: PropTypes.node.isRequired,
};

if the defaultProps property is required internally, it might be generated on fly based on the propTypes
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
N/A

Cheers

@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

These are two different systems, and it doesn't make sense to me to conflate them. People may not even use PropTypes (e.g. if they use TypeScript or Flow instead) but still use defaultProps.

I understanding it's tempting to reduce typing, but these are two separate concerns.

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

No branches or pull requests

2 participants