Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react/require-default-props not support type params of React Component #1724

Closed
pmizio opened this issue Mar 13, 2018 · 1 comment
Closed

Comments

@pmizio
Copy link
Contributor

pmizio commented Mar 13, 2018

When we define Component prop types like this:

type SelectProps = {
  isOpen?: boolean
}
class Select extends PureComponent<SelectProps, SelectState> {
  static defaultProps = {
    // isOpen: false,
  }
  ...
}

We don't get error like this:

17:3 error propType "isOpen" is not required, but has no corresponding defaultProp declaration react/require-default-props

To get this error we need to define component like this:

type SelectProps = {
  isOpen?: boolean
}
class Select extends PureComponent {
  props: SelectProps
  static defaultProps = {
    // isOpen: false,
  }
  ...
}

eslint v: ^4.17.0
eslint-plugin-react v: ^7.6.1

ljharb added a commit that referenced this issue Mar 28, 2018
Issue #1724 support for Flow generic PropTypes declaration in require-default-props rule
@ljharb
Copy link
Member

ljharb commented Mar 28, 2018

Fixed by #1733.

@ljharb ljharb closed this as completed Mar 28, 2018
This was referenced Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants