propType [name] is not required, but has no corresponding defaultProp declaration
See original GitHub issueI am using Flow for type checking, and I have something like this:
type Props = {
name?: ?string, // this means that "name" is NOT mandatory, and its value can be **null** or **undefined**
};
So, my question is, should I get this linting error? Is this the desired behavior?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
propType [name] is not required, but has no corresponding ...
It's explained in the documentation: https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values.
Read more >propType [name] is not required, but has no ... - GitHub
I am using Flow for type checking, and I have something like this: type Props = { name?: ?string, // this means that...
Read more >propType [name] is not required, but has no corresponding ...
Coding example for the question propType [name] is not required, but has no corresponding defaultProps declaration ReactJS-Reactjs.
Read more >Reactjs – propType [name] is not required, but has ... - iTecNote
Reactjs – propType [name] is not required, but has no corresponding defaultProps declaration ReactJS. reactjs. import styled from 'styled-components' import ...
Read more >How to Use PropTypes in React - freeCodeCamp
PropTypes are a good first line defense when it comes to debugging your apps. But before getting into detail about PropTypes, we have...
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
@AlexanderNaiden add:
I would say this is as expected. Since the prop is not required, you should specify a default value. You can decide to set it to
null
orundefined
by default.