Skip to content

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

@daniloster

Description

@daniloster

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions