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

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

Closed
jacobworrel opened this issue Apr 16, 2019 · 0 comments · Fixed by #2246
Closed

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

jacobworrel opened this issue Apr 16, 2019 · 0 comments · Fixed by #2246

Comments

@jacobworrel
Copy link

// 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.

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

Successfully merging a pull request may close this issue.

2 participants