Missing prop validation in React.FunctionComponent
See original GitHub issueTell us about your environment
- ESLint Version: v6.0.1
- Node Version: v10.16.0
- npm Version: v6.9.0
Configuration
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['@typescript-eslint'],
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
],
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import * as React from 'react';
interface PersonProps {
username: string;
}
const Person: React.FunctionComponent<PersonProps> = (props): React.ReactElement => (
<div>{props.username}</div>
);
npx eslint src --ext .tsx
What did you expect to happen?
eslint
show no errors, because type definition actually present in generic type React.FunctionComponent<PersonProps>
What actually happened? Please include the actual, raw output from ESLint.
error 'username' is missing in props validation react/prop-types
Issue Analytics
- State:
- Created 4 years ago
- Reactions:150
- Comments:79 (29 by maintainers)
Top Results From Across the Web
Missing prop validation in React.FunctionComponent #2353
I have a functional component. With a typescript props interface. When I access a property off of the prop. I get <property> is...
Read more >Props in functional component are missing in props validation
Eslint throwing eslint(react/prop-types) error despite already declared propTypes. I'm using eslint-plugin-react.
Read more >How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >is missing in props validation(react/prop-types) - You.com
You need to set the static property 'propTypes' on the component to satisfy this lint error. Here is some info about React's PropTypes:...
Read more >ReactJS - Props Validation - Tutorialspoint
ReactJS - Props Validation, Properties validation is a useful way to force the correct usage of the components. This will help during development...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Support or ignore prop-types in mixed JS/TypeScript projects
Adding
: PersonProps
(somewhat redundantly) seems to work…