13

I created a CRUD app using Redux so, I write code and when export the component I added this line:

AddContact.PropTypes = {
  addContact: PropTypes.func.isRequired
};

export default connect(null, { addContact })(AddContact);

But, It's showing this error

./src/components/contact/AddContact.js
  Line 461:12:  Typo in static class property declaration  react/no-typos
Search for the keywords to learn more about each error.
Ajeet Shah
  • 18,551
  • 8
  • 57
  • 87
Vijay208
  • 167
  • 1
  • 2
  • 10

3 Answers3

50

should be [p with lower key]

AddContact.propTypes

Documentation => https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-typos.md

14

The issue is in the casing.

we usually import PropTypes as:

import PropTypes from 'prop-types'

We imported as PropTypes But while using with a React component. we use it with smaller case propTypes . example.

Blog.propTypes = {
  blog: PropTypes.object.isRequired
}
Saurav gupta
  • 387
  • 3
  • 9
3

propTypes is a special property on your React.Component (AddContact in your case), so it is case sensitive.

Correcting AddContact.PropTypes to AddContact.propTypes will resolve it.

Read more from React Documentation.

Elisha Senoo
  • 3,489
  • 2
  • 22
  • 29