Typo in static class property declaration react/no-typos

Viewed 20747

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.
3 Answers

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
}

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.

Related