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

'react/no-unused-prop-types' reports false positives when using deep destructuring. #2444

Closed
IUnknown68 opened this issue Oct 4, 2019 · 2 comments

Comments

@IUnknown68
Copy link

When deep-destructuring component properties (in a functional component), 'react/no-unused-prop-types' is reported for the top level property:

import {
  intlShape,
  injectIntl,
} from 'react-intl';

import messages from './some-component.intl';

function SomeComponent({ intl: { formatMessage } }) {
  return (
    <img title={ formatMessage(messages.imageTitle) } />
  );
}

SomeComponent.displayName = 'SomeComponent';

SomeComponent.propTypes = {
  intl: intlShape.isRequired,
};

SomeComponent.defaultProps = {};

export default injectIntl(SomeComponent);

reports "'intl' PropType is defined but prop is never used".

Possible workaround:

function SomeComponent({ intl }) {
  const { formatMessage } = intl;
  return (
    <img title={ formatMessage(messages.imageTitle) } />
  );
}

I checked open issues, but didn't find any matching this exact case.

@golopot
Copy link
Contributor

golopot commented Oct 4, 2019

I am 97% sure this is a duplicate of #2424, and is fixed by #2428, but not yet released.

@IUnknown68
Copy link
Author

Yup, looks like it - didn't see that one for some reason. Thanks and have a good day!

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

No branches or pull requests

2 participants