error:
TypeError: Cannot read property 'type' of undefined
Occurred while linting /InputField.js:1
at /node_modules/eslint-plugin-react/lib/rules/prop-types.js:153:39
at Array.forEach (<anonymous>)
at /eslint-plugin-react/lib/rules/prop-types.js:152:26
at Array.forEach (<anonymous>)
at isDeclaredInDestructuredParam (/node_modules/eslint-plugin-react/lib/rules/prop-types.js:147:14)
at isDeclaredInComponent (/node_modules/eslint-plugin-react/lib/rules/prop-types.js:186:18)
at /node_modules/eslint-plugin-react/lib/rules/prop-types.js:201:13
at Array.filter (<anonymous>)
at reportUndeclaredPropTypes (/node_modules/eslint-plugin-react/lib/rules/prop-types.js:198:51)
at /node_modules/eslint-plugin-react/lib/rules/prop-types.js:223:11
InputField.js
import React from 'react'
const InputField = ({ input, meta: { touched, error }, cssClasses = {}, ...restProps }) => {
restProps.className = cssClasses.base
if (cssClasses.custom) {
restProps.className += ` ${cssClasses.custom}`
}
if (touched && error) {
restProps.className += ` ${cssClasses.error}`
}
return(
<input
{...input}
{...restProps}
/>
)
}
export default InputField
.eslintrc.js
module.exports = {
env: {
es6: true,
node: true,
},
extends: ['airbnb'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['react', 'import', 'jsx-a11y'],
overrides: [
{
files: ['**/*.spec.js', '**/*.spec.jsx'],
env: {
jest: true,
},
},
],
rules: {
semi: ['error', 'never', { beforeStatementContinuationChars: 'always' }],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
// "react/prop-types": 0, // when uncomment - no error.
},
}
versions:
"eslint": "^7.9.0",
"eslint-plugin-react": "^7.21.0",
This issue is still reproducible for ExperimentalRestProperty, do you want me to create a different issue or reopen?
A PR with a failing test case would be ideal. Thanks!
Any chance to release this fix? Seeing the tag but not the release in npm
It's only been 2 days. It'll be released when I have time.
@ljharb i would be really appreciated if you release it as quick as possible.
v7.21.3 is released.
Most helpful comment
v7.21.3 is released.