question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

propType [name] is not required, but has no corresponding defaultProp declaration

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

96reactions
ljharbcommented, Dec 21, 2017

@AlexanderNaiden add:

Switcher.defaultProps = {
  isSmall: false,
};
20reactions
jseminckcommented, Sep 14, 2017

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 or undefined by default.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found