Skip to content

prop-types not enforced with destructured props and default empty object param #2241

Closed
@jacobworrel

Description

@jacobworrel
// complains about 'baz' missing from prop-types validation
const Component = ({ foo, bar, baz }) => (
  // ...JSX
);

// doesn't complain about 'baz' missing from prop-types validation
const Component = ({ foo, bar, baz } = {}) => (
  // ...JSX
);

Component.propTypes = {
  foo: PropTypes.string,
  bar: PropTypes.string,
};

Since it's generally best-practice to provide defaults when destructuring, it would be nice if passing an empty object as a default param didn't break prop-types validation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions