eslint-plugin-react: '(react/prop-types): Missing in props validation' when props interface extends from another
code snippet
import React, { SFC } from 'react';
const mapDispatch = (dispatch: storeDispatch) => ({
removeCollection: dispatch.infoLibTable.removeCollection,
});
interface InfoLibTableProps extends ReturnType<typeof mapDispatch> {
}
const App: SFC<InfoLibTableProps> = (props) => {
props.removeCollection();
}
.eslintrc
{
"plugins": [ "eslint-plugin-react"]
}
when running eslint , I got the following warning:
warning 'removeCollection' is missing in props validation react/prop-types
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 27
- Comments: 41 (10 by maintainers)
Commits related to this issue
- chore(eslint): downgrades eslint-plugin-react because of a bug https://github.com/yannickcr/eslint-plugin-react/issues/2654 — committed to goooseman/dostoevsky-website by goooseman 4 years ago
- [Fix] `no-typos`/`no-unused-state`/propType detection: Support typescript props interface extension and TSTypeAliasDeclaration Fixes #2654. Fixes #2719. Fixes #2703. — committed to hank121314/eslint-plugin-react by hank121314 4 years ago
- [Fix] `no-typos`/`no-unused-state`/propType detection: Support typescript props interface extension and TSTypeAliasDeclaration Fixes #2654. Fixes #2719. Fixes #2703. — committed to hank121314/eslint-plugin-react by hank121314 4 years ago
- [Fix] `no-typos`/`no-unused-state`/propType detection: Support typescript props interface extension and TSTypeAliasDeclaration Fixes #2654. Fixes #2719. Fixes #2703. — committed to hank121314/eslint-plugin-react by hank121314 4 years ago
- [Fix] `no-typos`/`no-unused-prop-types`/propType detection: Support typescript props interface extension and TSTypeAliasDeclaration Fixes #2654. Fixes #2719. Fixes #2703. Co-authored-by: Hank Chen <... — committed to hank121314/eslint-plugin-react by hank121314 4 years ago
@ljharb upgrading to the latest version
7.21.1fixes thisI’m also having this problem using
React.FunctionalComponent, would be great to have this supported. My issue is as follows:This will give me the error that the props validation is missing
Using
eslint-plugin-react@7.20.3we are also seeing the issue.Example:
It’ll complain about the prop from the extended interface
onClosemissing in props validation.The upgrade from 7.20.0 -> 7.20.1 seems to be causing the issue for me.
Reason: Seems like if you have used the word “props” in your objects this error gets triggered e.g. {name: “”, props: {…} } Those looking for a quick fix. Reverting version back to :
7.16.0and deleting your package-lock.json, node modules directory and then doingnpm installfixed this for usPS: we tried downgrading to
7.20and even7.18but were still getting the same error But this needs an immediate fix to stop builds from breaking.Yep, I’ve tried. And it was throwing the error, if Typescript interface has been used.
By downgrading back to 7.20.0 (without downgrading any of libraries deps) the problem is resolved, so I believe the problem appeared somewhere between 7.20.1 and 7.20.0
For me, upgrading eslint-plugin-react to the latest version 7.21.5 fixed this
This error actually occurs a second time in our code base after the upgrade:
Renaming
propsto something more sensible fixes this, but maybe it’s a hint for what’s going on.I also get this error for
xwith the following code since today’s run of “yarn upgrade”:While yarn upgrade also upgraded
eslint-plugin-reactfrom 7.20.0 to 7.20.1, this doesn’t seem to be the root cause if this error. Manually downgrading it to 7.20.0 or 7.19.0 still gives this error. I suspect it is due to one ofeslint-plugin-react’s dependencies.@zakur777 just like the last three comments; please file a new issue?
Hi @ljharb,
Would you know how to fix this issue without disable the eslint rule? I really wish this error can be fixed: (FYI, I am using typescript and material-ui)
@DamengRandom then please file a new issue?
in
v7.22.0this problem continues! I did downgrade to cited versions, but the issue persists. 😢moved my comment to new issue
The problem was solved by installing “prop-types” v15.7.2 for React v17.0.1. So, it’s not a bug, I think. Good luck with eslint plugin, it’s awesome!
@damiangreen if you click on the commit that closed the PR, you’ll see it’s not released in anything yet. So, the answer to your question is “the next release”.
I had the same problem. Turns out it didn’t like me returning a ternary. 🤷♂️