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-redux/no-unused-prop-types: False positive on props used within react-dnd dropSpec #3058

Closed
bhollis opened this issue Aug 29, 2021 · 5 comments
Labels

Comments

@bhollis
Copy link

bhollis commented Aug 29, 2021

Since upgrading to 7.25.0 I get false positives on prop types defined in TypeScript that are used within react-dnd dropSpec functions but not within the component itself. e.g. https://github.com/DestinyItemManager/DIM/blob/master/src/app/destiny1/loadout-builder/LoadoutBuilderDropTarget.tsx

@ljharb
Copy link
Member

ljharb commented Aug 30, 2021

This may be related to #3054.

@traverse
Copy link

Running into a similar issue reproducible with the following code

interface Props {
  propA: string
  propB: number // marked as unused
}

function MyComponent(props: Props) {
  someLogicThatUsesProps(props)
  
  return <div>{props.propA}</div>
}

function someLogicThatUsesProps(props: Props) {
  if (props.propA !== '') return props.propA
  if (props.propB !== 0) return props.propB

  return 'some default'
}

In my case there's a bit more logic involved and several more props but I think it gets the point across.

@ljharb
Copy link
Member

ljharb commented Aug 31, 2021

@traverse in that case, that's just the limits of static analysis - you should be destructuring props and passing things explicitly - props objects should never be directly passed anywhere else, for a number of reasons.

@bhollis
Copy link
Author

bhollis commented Sep 1, 2021

This is not fixed in 7.25.1.

@bhollis
Copy link
Author

bhollis commented Sep 1, 2021

Sorry, I didn't catch that this is in eslint-plugin-react-redux, not eslint-plugin-react.

@bhollis bhollis closed this as completed Sep 1, 2021
@ljharb ljharb added the invalid label Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants