Investigate usage of 'react/require-default-props' & 'react/default-props-match-prop-types'
See original GitHub issueRecently, the following was added to the .eslintrc.js
file to warn about new linting rules.
'react/require-default-props': ['warn'],
'react/default-props-match-prop-types': ['warn']
It seems like these should be errors, however, more research should be done. This issue is to investigate the new rules.
If the rules should be errors, then this issue will require code changes to conform to the new lint rules.
If the rules should be turned off, then only configuration changes will be necessary.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Eslint: Problem with default props in functional component ...
Eslint react plugin complain with this error ESLint: propType "gretting" is not required, but has no corresponding defaultProps declaration.( ...
Read more >Flow does not detect default Props · Issue #6644 - GitHub
I'm using Eslint with this rules : "react/require-default-props". Which basically means : if a props is required, you have to not set ...
Read more >A complete guide to React default props - LogRocket Blog
Cover three ways to implement default props in React and provide default values for props that are not required by the component.
Read more >Eslint Plugin React: React-specific Linting Rules for ESLint
Enforce all defaultProps are defined and not "required" in propTypes., react/destructuring-assignment, Enforce consistent usage of destructuring assignment ...
Read more >Default Props in React/TypeScript - DEV Community
To illustrate the issue, I'm gonna take something from a plain-ol' JS component, and convert it into a TS component. The stub of...
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
The react/require-default-props rule should be an error. If we do not set any default props, the undefined display should take place of the props that are not sent by the parent component. In execution, an undefined variable may cause the application to break if it is used and there are no safety precautions in place. We do not want that to occur. Furthermore, we should set a defaultProps value, and when a prop is missing, the defaultProps value will replace the undefined.
The react/default-props-match-prop-types rule should be turned off. In the naming convention used in code, variable names usually have the same name as its props variable, even if they are not in the same file. PropTypes exports are for validating the data type is match and valid. Look like the default-props-match-prop-types is a kind of fixed shape. It seems not necessary in this case. Furthermore, projects have interfaces that provide the benefit of type-checking values shape. The props that are passed around normally follow interface rules. Interface set or applies the requirement properties and their type. When we try to use the properties for the variable, the system just checks did the object we pass to the function meets the requirements listed. The interface can be extended and changed to fit the need of the application, Prop types of the default drop might be changing while calling by different functions.
@fox1t