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 doesn't complain about destructured props in stateless functions #354

Closed
kesne opened this issue Dec 8, 2015 · 3 comments · Fixed by #430
Closed

prop-types doesn't complain about destructured props in stateless functions #354

kesne opened this issue Dec 8, 2015 · 3 comments · Fixed by #430

Comments

@kesne
Copy link

kesne commented Dec 8, 2015

The following should cause an error for missing proptype validations, but it doesn't.

const Test = ({ name }) => {
  return (
    <div>{name}</div>
  );
};

If you replace the destructuring with using the props object, it works as expected.

@yannickcr
Copy link
Member

Yep, this pattern is not actually handled.

@ljharb
Copy link
Member

ljharb commented Jan 21, 2016

Would love to see this handled, since it's the primary pattern people seem to use for functional stateless components.

@ljharb
Copy link
Member

ljharb commented Feb 2, 2016

Any progress on this?

lencioni added a commit to lencioni/eslint-plugin-react that referenced this issue Feb 6, 2016
The following should cause an error for missing propType validations,
but it doesn't.

  const Test = ({ name }) => {
    return (
      <div>{name}</div>
    );
  };

If you replace the destructuring with using the props object, it works
as expected. This commit fixes this problem.

Fixes jsx-eslint#354.
lencioni added a commit to lencioni/eslint-plugin-react that referenced this issue Feb 6, 2016
The following should cause an error for missing propType validations,
but it doesn't.

  const Test = ({ name }) => {
    return (
      <div>{name}</div>
    );
  };

If you replace the destructuring with using the props object, it works
as expected. This commit fixes this problem.

Fixes jsx-eslint#354.
yannickcr added a commit that referenced this issue Feb 7, 2016
Add support to prop-types for destructing in function signatures (fixes #354)
lencioni added a commit to lencioni/eslint-plugin-react that referenced this issue Feb 13, 2016
The following should cause an error for missing propType validations,
but it doesn't.

  const Test = ({ name }) => {
    return (
      <div>{name}</div>
    );
  };

If you replace the destructuring with using the props object, it works
as expected. This commit fixes this problem.

Fixes jsx-eslint#354.
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.

3 participants